Part Number Hot Search : 
MSP4408G 68HC70 0459854 APT30 N60CF 0459854 S21190HR APT30
Product Description
Full Text Search
 

To Download PIC16LF723A Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2010 microchip technology inc. ds41417a pic16f/lf722a/723a data sheet 28-pin flash microcontrollers with nanowatt xlp technology
ds41417a-page 2 ? 2010 microchip technology inc. information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. microchip makes no representations or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose . microchip disclaims all liability arising from this information and its use. use of microchip devices in life support and/or safety applications is entirely at the buyer?s risk, and the buyer agrees to defend, indemnify and hold harmless microchip from any and all damages, claims, suits, or expenses resulting from such use. no licenses are conveyed, implicitly or otherwise, under any microchip intellectual property rights. trademarks the microchip name and logo, the microchip logo, dspic, k ee l oq , k ee l oq logo, mplab, pic, picmicro, picstart, pic 32 logo, rfpic and uni/o are registered trademarks of microchip technology incorporated in the u.s.a. and other countries. filterlab, hampshire, hi-tech c, linear active thermistor, mxdev, mxlab, seeval and the embedded control solutions company are registered trademarks of microchip technology incorporated in the u.s.a. analog-for-the-digital age, appl ication maestro, codeguard, dspicdem, dspicdem.net, dspicworks, dsspeak, ecan, economonitor, fansense, hi-tide, in-circuit serial programming, icsp, mindi, miwi, mpasm, mplab certified logo, mplib, mplink, mtouch, octopus, omniscient code generation, picc, picc-18, picdem, picdem.net, pickit, pictail, real ice, rflab, select mode, total endurance, tsharc, uniwindriver, wiperlock and zena are trademarks of microchip tec hnology incorporated in the u.s.a. and other countries. sqtp is a service mark of microchip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2010, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. isbn: 978-1-60932-120-8 note the following details of the code protection feature on microchip devices: ? microchip products meet the specification cont ained in their particular microchip data sheet. ? microchip believes that its family of products is one of the mo st secure families of its kind on the market today, when used i n the intended manner and under normal conditions. ? there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip produc ts in a manner outside the operating specifications contained in microchip?s data sheets. most likely, the person doing so is engaged in theft of intellectual property. ? microchip is willing to work with the customer who is concerned about the integrity of their code. ? neither microchip nor any other semiconductor manufacturer c an guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ?unbreakable.? code protection is constantly evolving. we at microchip are co mmitted to continuously improvi ng the code protection features of our products. attempts to break microchip?s c ode protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona; gresham, oregon and design centers in california and india. the company?s quality system processes and procedures are for its pic ? mcus and dspic ? dscs, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory and analog products. in addition, microchip?s quality system for the design and manufacture of development systems is iso 9001:2000 certified.
? 2010 microchip technology inc. ds41417a-page 3 pic16f/lf722a/723a devices included in this data sheet: pic16f722a/723a devices: pic16lf722a/723a devices: high-performance risc cpu: ? only 35 instructions to learn: - all single-cycle instructions except branches ? operating speed: - dc ? 20 mhz oscillator/clock input - dc ? 200 ns instruction cycle ? up to 4k x 14 words of flash program memory ? up to 192 bytes of data memory (ram) ? interrupt capability ? 8-level deep hardware stack ? direct, indirect and relative addressing modes ? processor read access to program memory ? pinout compatible to other 28-pin pic16cxxx and pic16fxxx microcontrollers special microcontroller features: ? precision internal oscillator: - 16 mhz or 500 khz operation - factory calibrated to 1%, typical - software tunable - software selectable 1, 2, 4 or 8 divider ? 1.8v-5.5v operation ? pic16f722a/723a ? 1.8v-3.6v operation ? pic16lf722a/723a ? power-on reset (por), power-up timer (pwrt) and oscillator start-up timer (ost) ? brown-out reset (bor): - selectable between two trip points - disable in sleep option ? programmable code protection ? in-circuit serial programming tm (icsp tm ) via two pins ? multiplexed master clear with pull-up/input pin ? industrial and extended temperature range ? high-endurance flash cell: - 1,000 write flash endurance (typical) - flash retention: > 40 years ? power-saving sleep mode extreme low-power management pic16lf722a/723a with nanowatt xlp: ? sleep mode: 20 na ? watchdog timer: 500 na ? timer1 oscillator: 600 na @ 32 khz analog features: ? a/d converter: - 8-bit resolution and up to 14 channels - conversion available during sleep - selectable 1.024/2.048/4.096v voltage reference ? on-chip 3.2v regulator (pic16f722a/723a devices only) peripheral highlights: ? up to 24 i/o pins and 1 input-only pin: - high-current source/sink for direct led drive - interrupt-on-pin change - individually programmable weak pull-ups ? timer0: 8-bit timer/counter with 8-bit prescaler ? enhanced timer1: - dedicated low-power 32 khz oscillator - 16-bit timer/counter with prescaler - external gate input mode with toggle and single shot modes - interrupt-on-gate completion ? timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler ? two capture, compare, pwm (ccp) modules: - 16-bit capture, max. resolution 12.5 ns - 16-bit compare, max. resolution 200 ns - 10-bit pwm, max. frequency 20 khz ? addressable universal synchronous asynchronous receiver transmitter (ausart) ? synchronous serial port (ssp): - spi (master/slave) -i 2 c tm (slave) with address mask ?mtouch tm sensing oscillator module: - up to 16 input channels ? pic16f722a ? pic16f723a ? pic16lf722a ? PIC16LF723A 28-pin flash microcontrollers with nanowatt xlp technology
pic16f/lf722a/723a ds41417a-page 4 ? 2010 microchip technology inc. device program memory flash (words) sram (bytes) i/os interrupts 8-bit a/d (ch) ausart ccp timers 8/16-bit pic16f722a/ pic16lf722a 2048 128 25 12 11 yes 2 2/1 pic16f723a/ PIC16LF723A 4096 192 25 12 11 yes 2 2/1
? 2010 microchip technology inc. ds41417a-page 5 pic16f/lf722a/723a pin diagrams ? 28-pin pdip/soic/ssop/qfn/uqfn (pic16f/lf722a/723a) pic16f722a/723a pic16lf722a/723a 1 2 3 4 5 6 7 8 9 10 v pp /mclr /re3 v cap (3) /ss (2) /an0/ra0 an1/ra1 an2/ra2 v ref /an3/ra3 t0cki/cps6/ra4 v cap (3) / ss (2) /cps7/an4/ra5 rb6/icspclk rb5/an13/cps5/t1g rb4/an11/cps4 rb3/an9/cps3/ccp2 (1) rb2/an8/cps2 rb1/an10/cps1 rb0/an12/cps0/int v dd v ss 11 12 13 14 15 16 17 18 19 20 28 27 26 25 24 23 22 21 v ss clkin/osc1/ra7 v cap (3) / clkout/osc2/ra6 t1cki/t1oso/rc0 ccp2 (1) /t1osi/rc1 ccp1/rc2 scl/sck/rc3 rc5/sdo rc4/sdi/sda rc7/rx/dt rc6/tx/ck rb7/icspdat 2 3 6 1 18 19 20 21 15 7 16 17 t1cki/t1oso/rc0 5 4 rb7/icspdat rb6/icspclk rb5/an13/cps5/t1g rb4/an11/cps4 rb3/an9/cps3/ccp2 (1) rb2/an8/cps2 rb1/an10/cps1 rb0/an12/cps0/int v dd v ss rc7/rx/dt ck/tx/rc6 sdo/rc5 sda/sdi/rc4 re3/mclr /v pp ra0/an0/ss (2) /v cap (3) ra1/an1 an2/ra2 v ref /an3/ra3 t0cki/cps6/ra4 v cap (3) /ss (2) /cps7/an4/ra5 v ss clkin/osc1/ra7 v cap (3) /clkout/osc2/ra6 ccp2 (1) /t1osi/rc1 ccp1/rc2 scl/sck/rc3 9 10 13 8 14 12 11 27 26 23 28 22 24 25 pic16f722a/723a pic16lf722a/723a note 1: ccp2 pin location may be selected as rb3 or rc1. 2: ss pin location may be selected as ra5 or ra0. 3: pic16f722a/723a devices only. pdip, soic, ssop qfn, uqfn
pic16f/lf722a/723a ds41417a-page 6 ? 2010 microchip technology inc. table 1: 28-pin pdip/soic/ssop/qfn/u qfn summary (pic16f/lf722a/723a) i/o 28-pin pdip, soic, ssop 28-pin qfn, uqfn a/d cap sensor timers ccp ausart ssp interrupt pull-up basic ra0 2 27 an0 ? ? ? ? ss (3) ? ? v cap (4) ra1 3 28 an1 ? ? ? ? ? ? ? ? ra2 4 1 an2 ? ? ? ? ? ? ? ? ra3 5 2 an3/v ref ??????? ? ra4 6 3 ? cps6 t0cki ? ? ? ? ? ? ra5 7 4 an4 cps7 ? ? ? ss (3) ?? v cap (4) ra6 10 7 ? ? ? ? ? ? ? ? osc2/clkout/v cap (4) ra7 9 6 ? ? ? ? ? ? ? ? osc1/clkin rb0 21 18 an12 cps0 ? ? ? ? ioc/int y ? rb1 22 19 an10 cps1 ? ? ? ? ioc y ? rb2 23 20 an8 cps2 ? ? ? ? ioc y ? rb3 24 21 an9 cps3 ? ccp2 (2) ? ? ioc y ? rb4 25 22 an11 cps4 ? ? ? ? ioc y ? rb5 26 23 an13 cps5 t1g ? ? ? ioc y ? rb6 27 24 ? ? ? ? ? ? ioc y icspclk/icdclk rb7 28 25 ? ? ? ? ? ? ioc y icspdat/icddat rc0 11 8 ? ? t1oso/t1cki ? ? ? ? ? ? rc1 12 9 ? ? t1osi ccp2 (2) ???? ? rc2 13 10 ? ? ? ccp1 ? ? ? ? ? rc3 14 11 ? ? ? ? ? sck/scl ? ? ? rc4 15 12 ? ? ? ? sdi/sda ? ? ? rc5 16 13 ? ? ? ? ? sdo ? ? ? rc6 17 14 ? ? ? ? tx/ck ? ? ? ? rc7 18 15 ? ? ? ? rx/dt ? ? ? ? re3 1 26 ? ? ? ? ? ? ? y (1) mclr /v pp ?2017 ? ? ? ? ? ? ? ? v dd ? 8,19 5,16 ? ? ? ? ? ? ? ? v ss note 1: pull-up enabled only with external mclr configuration. 2: rc1 is the default pin location for ccp2. rb3 may be selected by changing the ccp2sel bit in the apfcon register. 3: ra5 is the default pin location for ss . ra0 may be selected by changing the sssel bit in the apfcon register. 4: pic16f722a/723a devices only. note: the pic16f722a/723a devices have an internal low dropout voltage regulator. an external capacitor must be connected to one of the available v cap pins to stabilize the regulator. for more information, see section 5.0 ?low dropout (ldo) voltage regulator? . the pic16lf722a/723a devices do not have the voltage regulator and therefore no external capacitor is required.
? 2010 microchip technology inc. ds41417a-page 7 pic16f/lf722a/723a table of contents 1.0 device overview ............................................................................................................ ............................................................. 9 2.0 memory organization ......................................................................................................... ....................................................... 15 3.0 resets ...................................................................................................................... ................................................................. 27 4.0 interrupts .................................................................................................................. ................................................................. 37 5.0 low dropout (ldo) voltage regulator ......................................................................................... ............................................ 45 6.0 i/o ports ................................................................................................................... ................................................................. 47 7.0 oscillator module........................................................................................................... ............................................................ 77 8.0 device configuration ........................................................................................................ .......................................................... 83 9.0 analog-to-digital converter (adc) module .................................................................................... ........................................... 87 10.0 fixed voltage reference.................................................................................................... ....................................................... 97 11.0 timer0 module .............................................................................................................. ............................................................ 99 12.0 timer1 module with gate control............................................................................................ ................................................ 103 13.0 timer2 module .............................................................................................................. .......................................................... 115 14.0 capacitive sensing module.................................................................................................. ................................................... 117 15.0 capture/compare/pwm (ccp) module ........................................................................................... ....................................... 123 16.0 addressable universal synchronous asynchr onous receiver transmitter (ausart) ............................................... ........... 133 17.0 ssp module overview ........................................................................................................ .................................................... 155 18.0 program memory read ........................................................................................................ ................................................... 177 19.0 power-down mode (sleep) .................................................................................................... ................................................. 181 20.0 in-circuit serial programming? (icsp?) ..................................................................................... ......................................... 183 21.0 instruction set summary .................................................................................................... ..................................................... 185 22.0 development support........................................................................................................ ...................................................... 195 23.0 electrical specifications.................................................................................................. ......................................................... 199 24.0 dc and ac characteristics graphs and charts ................................................................................ ...................................... 227 25.0 packaging information...................................................................................................... ....................................................... 263 appendix a: data sheet revision history........................................................................................ ................................................. 273 appendix b: migrating from other pic ? devices....................................................................................................................... ...... 273 the microchip web site ......................................................................................................... ........................................................... 281 customer change notification service ........................................................................................... .................................................. 281 customer support .............................................................................................................. ............................................................... 281 reader response ................................................................................................................ ............................................................. 282 product identification system .................................................................................................. .......................................................... 283
pic16f/lf722a/723a ds41417a-page 8 ? 2010 microchip technology inc. to our valued customers it is our intention to provide our valued customers with the be st documentation possible to ensure successful use of your micro chip products. to this end, we will continue to improve our publications to better suit your needs. our publications will be refined and enhanced as new volumes and updates are introduced. if you have any questions or comments regardi ng this publication, please contact the marketing communications department via e-mail at docerrors@microchip.com or fax the reader response form in the back of this data sheet to (480) 792-4150. we welcome your feedback. most current data sheet to obtain the most up-to-date version of this data s heet, please register at our worldwide web site at: http://www.microchip.com you can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page . the last character of the literature number is the vers ion number, (e.g., ds30000a is version a of document ds30000). errata an errata sheet, describing minor operational differences fr om the data sheet and recommended workarounds, may exist for curren t devices. as device/documentation issues become known to us, we will publish an errata sheet. the errata will specify the revisi on of silicon and revision of document to which it applies. to determine if an errata sheet exists for a particular device, please check with one of the following: ? microchip?s worldwide web site; http://www.microchip.com ? your local microchip sales office (see last page) when contacting a sales office, please specify which device, re vision of silicon and data sheet (include literature number) you are using. customer notification system register on our web site at www.microchip.com to receive the most current information on all of our products.
? 2010 microchip technology inc. ds41417a-page 9 pic16f/lf722a/723a 1.0 device overview the pic16f/lf722a/723a devices are covered by this data sheet. they are available in 28-pin packages. figure 1-1 shows a block diagram of the pic16f/lf722a/723a devices. table 1-1 shows the pinout descriptions.
pic16f/lf722a/723a ds41417a-page 10 ? 2010 microchip technology inc. figure 1-1: pic16f/lf7 22a/723a block diagram 13 data bus 8 14 program bus instruction reg program counter 8 level stack (13-bit) direct addr 7 ram addr 9 addr mux indirect addr fsr reg status reg mux alu w reg power-up timer oscillator start-up timer power-on reset watchdog timer instruction decode & control timing generation osc1/clkin osc2/clkout mclr v dd porta ra4 rc0 rc1 rc2 rc3 rc4 rc5 rc6 rc7 8 8 brown-out reset ausart timer0 timer1 timer2 ra3 ra1 ra0 8 3 analog-to-digital converter ra6 ra7 rb6 rb7 v ss t0cki t1g t1cki v ref synchronous sda scl ss sdo serial port sdi/ sck/ tx/ck rx/dt internal oscillator block configuration 13 data bus 8 14 program bus instruction reg program counter 8 level stack (13-bit) direct addr 7 ram addr addr mux indirect addr fsr reg status reg mux alu w reg power-up timer oscillator start-up timer power-on reset watchdog timer instruction decode & control timing generation mclr v dd rc1 8 8 brown-out reset ausart timer0 timer1 timer2 8 3 v ss t0cki t1cki synchronous sda scl ss sdo serial port sdi/ sck/ internal oscillator block configuration 13 data bus 8 14 program bus instruction reg program counter 8 level stack (13-bit) direct addr 7 ram addr addr mux indirect addr fsr reg status reg mux alu w reg power-up timer oscillator start-up timer power-on reset watchdog timer instruction decode and control timing generation mclr v dd portb portc ra5 8 8 brown-out reset timer0 timer1 timer2 ra2 8 3 rb0 rb1 rb2 rb3 rb4 rb5 v ss t0cki t1cki synchronous sda scl ss sdo serial port sdi/ sck/ internal oscillator block configuration ccp2 ccp2 timer1 32 khz oscillator porte re3 ccp1 ccp1 t1osi t1oso an9 an0 an1 an2 an3 an4 an8 an10 an11 an12 an13 ldo (1) regulator flash program memory note 1: pic16f722a/723a only. ram capacitive sensing module cps6 cps0 cps1 cps2 cps3 cps4 cps5 cps7
? 2010 microchip technology inc. ds41417a-page 11 pic16f/lf722a/723a table 1-1: pic16f722a/723a pinout description name function input type output type description ra0/an0/ss /v cap ra0 ttl cmos general purpose i/o. an0 an ? a/d channel 0 input. ss st ? slave select input. v cap power power filter capacitor for voltage regulator (pic16f722a/723a only). ra1/an1 ra1 ttl cmos general purpose i/o. an1 an ? a/d channel 1 input. ra2/an2 ra2 ttl cmos general purpose i/o. an2 an ? a/d channel 2 input. ra3/an3/v ref ra3 ttl cmos general purpose i/o. an3 an ? a/d channel 3 input. v ref an ? a/d voltage reference input. ra4/cps6/t0cki ra4 ttl cmos general purpose i/o. cps6 an ? capacitive sensing input 6. t0cki st ? timer0 clock input. ra5/an4/cps7/ss/ v cap ra5 ttl cmos general purpose i/o. an4 an ? a/d channel 4 input. cps7 an ? capacitive sensing input 7. ss st ? slave select input. v cap power power filter capacitor for voltage regulator (pic16f722a/723a only). ra6/osc2/clkout/v cap ra6 ttl cmos general purpose i/o. osc2 ? xtal crystal/resonator (lp, xt, hs modes). clkout ? cmos f osc /4 output. v cap power power filter capacitor for voltage regulator (pic16f722a/723a only). ra7/osc1/clkin ra7 ttl cmos general purpose i/o. osc1 xtal ? crystal/resonator (lp, xt, hs modes). clkin cmos ? external clock input (ec mode). clkin st ? rc oscillator connection (rc mode). rb0/an12/cps0/int rb0 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. an12 an ? a/d channel 12 input. cps0 an ? capacitive sensing input 0. int st ? external interrupt. rb1/an10/cps1 rb1 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. an10 an ? a/d channel 10 input. cps1 an ? capacitive sensing input 1. rb2/an8/cps2 rb2 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. an8 an ? a/d channel 8 input. cps2 an ? capacitive sensing input 2. rb3/an9/cps3/ccp2 rb3 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. an9 an ? a/d channel 9 input. cps3 an ? capacitive sensing input 3. ccp2 st cmos capture/compare/pwm2. legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels i 2 c?= schmitt trigger input with i 2 c hv = high voltage xtal = crystal levels
pic16f/lf722a/723a ds41417a-page 12 ? 2010 microchip technology inc. rb4/an11/cps4 rb4 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. an11 an ? a/d channel 11 input. cps4 an ? capacitive sensing input 4. rb5/an13/cps5/t1g rb5 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. an13 an ? a/d channel 13 input. cps5 an ? capacitive sensing input 5. t1g st ? timer1 gate input. rb6/icspclk/icdclk rb6 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. icspclk st ? serial programming clock. icdclk st ? in-circuit debug clock. rb7/icspdat/icddat rb7 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. icspdat st cmos icsp? data i/o. icddat st ? in-circuit data i/o. rc0/t1oso/t1cki rc0 st cmos general purpose i/o. t1oso xtal xtal timer1 oscillator connection. t1cki st ? timer1 clock input. rc1/t1osi/ccp2 rc1 st cmos general purpose i/o. t1osi xtal xtal timer1 oscillator connection. ccp2 st cmos capture/compare/pwm2. rc2/ccp1 rc2 st cmos general purpose i/o. ccp1 st cmos capture/compare/pwm1. rc3/sck/scl rc3 st cmos general purpose i/o. sck st cmos spi clock. scl i 2 c? od i 2 c? clock. rc4/sdi/sda rc4 st cmos general purpose i/o. sdi st ? spi data input. sda i 2 c? od i 2 c? data input/output. rc5/sdo rc5 st cmos general purpose i/o. sdo ? cmos spi data output. rc6/tx/ck rc6 st cmos general purpose i/o. tx ? cmos usart asynchronous transmit. ck st cmos usart synchronous clock. rc7/rx/dt rc7 st cmos general purpose i/o. rx st ? usart asynchronous input. dt st cmos usart synchronous data. re3/mclr /v pp re3 ttl ? general purpose input. mclr st ? master clear with internal pull-up. v pp hv ? programming voltage. v dd v dd power ? positive supply. v ss v ss power ? ground reference. table 1-1: pic16f722a/723a pi nout description (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels i 2 c?= schmitt trigger input with i 2 c hv = high voltage xtal = crystal levels
? 2010 microchip technology inc. ds41417a-page 13 pic16f/lf722a/723a note: the pic16f722a/723a devices have an internal low dropout voltage regulator. an external capacitor must be connected to one of the available v cap pins to stabilize the regulator. for more information, see section 5.0 ?low dropout (ldo) voltage regulator? . the pic16lf722a/723a devices do not have the voltage regulator and therefore no external capacitor is required.
pic16f/lf722a/723a ds41417a-page 14 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 15 pic16f/lf722a/723a 2.0 memory organization 2.1 program memory organization the pic16f/lf722a/723a has a 13-bit program counter capable of addressing a 2k x 14 program memory space for the pic16f/lf722a (0000h-07ffh) and a 4k x 14 program memory space for the pic16f/lf723a (0000h-0fffh). accessing a location above the memory boundaries for the pic16f/lf722a will cause a wrap-around within the first 2k x 14 program memory space. accessing a location above the memory boundaries for the pic16f/lf723a will cause a wrap-around within the first 4k x 14 program memory space. the reset vector is at 0000h and the interrupt vector is at 0004h. figure 2-1: program memory map and stack for the pic16f/lf722a figure 2-2: program memory map and stack for the pic16f/lf723a pc<12:0> 13 0000h 0004h stack level 1 stack level 8 reset vector interrupt vector call, return retfie, retlw stack level 2 0005h on-chip program memory page 0 07ffh wraps to page 0 wraps to page 0 wraps to page 0 0800h 0fffh 1000h 17ffh 1800h 1fffh pc<12:0> 13 0000h 0004h stack level 1 stack level 8 reset vector interrupt vector call, return retfie, retlw stack level 2 0005h on-chip program memory page 0 page 1 07ffh 0800h 0fffh wraps to page 0 wraps to page 1 1000h 17ffh 1800h 1fffh
pic16f/lf722a/723a ds41417a-page 16 ? 2010 microchip technology inc. 2.2 data memory organization the data memory is partitioned into multiple banks which contain the general purpose registers (gprs) and the special function registers (sfrs). bits rp0 and rp1 are bank select bits. rp1 rp0 00 ? bank 0 is selected 01 ? bank 1 is selected 10 ? bank 2 is selected 11 ? bank 3 is selected each bank extends up to 7fh (128 bytes). the lower locations of each bank are reserved for the special function registers. above the special function registers are the general purpose registers, implemented as static ram. all implemented banks contain special function registers. some frequently used special function registers from one bank are mirrored in another bank for code reduction and quicker access. 2.2.1 general purpose register file the register file is organized as 128 x 8 bits in the pic16f/lf722a and 192 x 8 bits in the pic16f/lf723a. each register is accessed either directly or indirectly through the file select register (fsr), (refer to section 2.5 ?indirect addressing, indf and fsr registers? ). 2.2.2 special function registers the special function registers are registers used by the cpu and peripheral functions for controlling the desired operation of the device (refer to table 2-1). these registers are static ram. the special function registers can be classified into two sets: core and peripheral. the special function registers associated with the ?core? are described in this section. those related to the operation of the peripheral features are described in the section of that peripheral feature.
? 2010 microchip technology inc. ds41417a-page 17 pic16f/lf722a/723a figure 2-3: pic16f/lf722a spec ial function registers file address indirect addr. (*) 00h indirect addr. (*) 80h indirect addr. (*) 100h indirect addr. (*) 180h tmr0 01h option 81h tmr0 101h option 181h pcl 02h pcl 82h pcl 102h pcl 182h status 03h status 83h status 103h status 183h fsr 04h fsr 84h fsr 104h fsr 184h porta 05h trisa 85h 105h ansela 185h portb 06h trisb 86h 106h anselb 186h portc 07h trisc 87h 107h 187h 08h 88h cpscon0 108h 188h porte 09h trise 89h cpscon1 109h 189h pclath 0ah pclath 8ah pclath 10ah pclath 18ah intcon 0bh intcon 8bh intcon 10bh intcon 18bh pir1 0ch pie1 8ch pmdatl 10ch pmcon1 18ch pir2 0dh pie2 8dh pmadrl 10dh reserved 18dh tmr1l 0eh pcon 8eh pmdath 10eh reserved 18eh tmr1h 0fh t1gcon 8fh pmadrh 10fh reserved 18fh t1con 10h osccon 90h 110h 190h tmr2 11h osctune 91h 111h 191h t2con 12h pr2 92h 112h 192h sspbuf 13h sspadd/sspmsk 93h 113h 193h sspcon 14h sspstat 94h 114h 194h ccpr1l 15h wpub 95h 115h 195h ccpr1h 16h iocb 96h 116h 196h ccp1con 17h 97h 117h 197h rcsta 18h txsta 98h 118h 198h txreg 19h spbrg 99h 119h 199h rcreg 1ah 9ah 11ah 19ah ccpr2l 1bh 9bh 11bh 19bh ccpr2h 1ch apfcon 9ch 11ch 19ch ccp2con 1dh fvrcon 9dh 11dh 19dh adres 1eh 9eh 11eh 19eh adcon0 1fh adcon1 9fh 11fh 19fh general purpose register 96 bytes 20h general purpose register 32 bytes a0h bfh 120h 1a0h c0h efh 16fh 1efh accesses 70h-7fh f0h accesses 70h-7fh 170h accesses 70h-7fh 1f0h 7fh ffh 17fh 1ffh bank 0 bank 1 bank 2 bank 3 legend: = unimplemented data memory locations, read as ? 0 ?. * = not a physical register.
pic16f/lf722a/723a ds41417a-page 18 ? 2010 microchip technology inc. figure 2-4: pic16f/lf723a special function registers legend: = unimplemented data memory locations, read as ? 0 ?. * = not a physical register. file address indirect addr. (*) 00h indirect addr. (*) 80h indirect addr. (*) 100h indirect addr. (*) 180h tmr0 01h option 81h tmr0 101h option 181h pcl 02h pcl 82h pcl 102h pcl 182h status 03h status 83h status 103h status 183h fsr 04h fsr 84h fsr 104h fsr 184h porta 05h trisa 85h 105h ansela 185h portb 06h trisb 86h 106h anselb 186h portc 07h trisc 87h 107h 187h 08h 88h cpscon0 108h 188h porte 09h trise 89h cpscon1 109h 189h pclath 0ah pclath 8ah pclath 10ah pclath 18ah intcon 0bh intcon 8bh intcon 10bh intcon 18bh pir1 0ch pie1 8ch pmdatl 10ch pmcon1 18ch pir2 0dh pie2 8dh pmadrl 10dh reserved 18dh tmr1l 0eh pcon 8eh pmdath 10eh reserved 18eh tmr1h 0fh t1gcon 8fh pmadrh 10fh reserved 18fh t1con 10h osccon 90h 110h 190h tmr2 11h osctune 91h 111h 191h t2con 12h pr2 92h 112h 192h sspbuf 13h sspadd/sspmsk 93h 113h 193h sspcon 14h sspstat 94h 114h 194h ccpr1l 15h wpub 95h 115h 195h ccpr1h 16h iocb 96h 116h 196h ccp1con 17h 97h 117h 197h rcsta 18h txsta 98h 118h 198h txreg 19h spbrg 99h 119h 199h rcreg 1ah 9ah 11ah 19ah ccpr2l 1bh 9bh 11bh 19bh ccpr2h 1ch apfcon 9ch 11ch 19ch ccp2con 1dh fvrcon 9dh 11dh 19dh adres 1eh 9eh 11eh 19eh adcon0 1fh adcon1 9fh 11fh 19fh general purpose register 96 bytes 20h 7fh general purpose register 80 bytes a0h efh general purpose register 16 bytes 120h 12fh 130h 16fh 1a0h 1efh accesses 70h-7fh f0h ffh accesses 70h-7fh 170h 17fh accesses 70h-7fh 1f0h 1ffh bank 0 bank 1 bank 2 bank 3
? 2010 microchip technology inc. ds41417a-page 19 pic16f/lf722a/723a table 2-1: pic16f/lf722a/723a special function register summary address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor page bank 0 00h (2) indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 26,34 01h tmr0 timer0 module register xxxx xxxx 99,34 02h (2) pcl program counter (pc) least significant byte 0000 0000 25,34 03h (2) status irp rp1 rp0 to pd zdcc 0001 1xxx 22,34 04h (2) fsr indirect data memory address pointer xxxx xxxx 26,34 05h porta ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 xxxx xxxx 48,34 06h portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx xxxx 57,34 07h portc rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 xxxx xxxx 67,34 09h porte ? ? ? ?re3 ? ? ? ---- xxxx 74,34 0ah (1, 2) pclath ? ? ? write buffer for the upper 5 bits of the program counter ---0 0000 25,34 0bh (2) intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 40,34 0ch pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 43,34 0dh pir2 ? ? ? ? ? ? ? ccp2if ---- ---0 44,34 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx 108,34 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx 108,34 10h t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 0000 00-0 112,34 11h tmr2 timer2 module register 0000 0000 115,34 12h t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 116,34 13h sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx 157,34 14h sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 174,34 15h ccpr1l capture/compare/pwm register (lsb) xxxx xxxx 125,34 16h ccpr1h capture/compare/pwm register (msb) xxxx xxxx 125,34 17h ccp1con ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 124,34 18h rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 143,34 19h txreg usart transmit data register 0000 0000 142,34 1ah rcreg usart receive data register 0000 0000 140,34 1bh ccpr2l capture/compare/pwm register 2 (lsb) xxxx xxxx 125,34 1ch ccpr2h capture/compare/pwm register 2 (msb) xxxx xxxx 125,34 1dh ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 124,34 1eh adres a/d result register xxxx xxxx 93,34 1fh adcon0 ? ? chs3 chs2 chs1 chs0 go/done adon --00 0000 92,34 legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<12:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: accessible only when sspm<3:0> = 1001 . 4: accessible only when sspm<3:0> ? 1001 . 5: this bit is always ? 1 ? as re3 is input only.
pic16f/lf722a/723a ds41417a-page 20 ? 2010 microchip technology inc. bank 1 80h (2) indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 26,34 81h option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 23,35 82h (2) pcl program counter (pc) least significant byte 0000 0000 25,34 83h (2) status irp rp1 rp0 to pd zdcc 0001 1xxx 22,34 84h (2) fsr indirect data memory address pointer xxxx xxxx 26,34 85h trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 48,35 86h trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 57,35 87h trisc trisc7 trisc6 trisc5 tr isc4 trisc3 trisc2 trisc1 trisc0 1111 1111 67,35 89h trise ? ? ? ? trise3 (5) ? ? ? ---- 1111 74,35 8ah (1, 2) pclath ? ? ? write buffer for the upper 5 bits of the program counter ---0 0000 25,34 8bh (2) intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 40,34 8ch pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 41,35 8dh pie2 ? ? ? ? ? ? ? ccp2ie ---- ---0 42,35 8eh pcon ? ? ? ? ? ?por bor ---- --qq 24,35 8fh t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/ done t1gval t1gss1 t1gss0 0000 0x00 113,35 90h osccon ? ? ircf1 ircf0 icsl icss ? ? --10 qq-- 79,35 91h osctune ? ? tun5 tun4 tun3 tun2 tun1 tun0 --00 0000 80,35 92h pr2 timer2 period register 1111 1111 115,35 93h sspadd (4) synchronous serial port (i 2 c ? mode) address register 0000 0000 165,35 93h sspmsk (3) synchronous serial port (i 2 c ? mode) address mask register 1111 1111 176,35 94h sspstat smp cke d/a psr/w ua bf 0000 0000 163,35 95h wpub wpub7 wpub6 wpub5 wpub4 wpub3 wpub2 wpub1 wpub0 1111 1111 57,35 96h iocb iocb7 iocb6 iocb5 iocb4 iocb3 iocb2 iocb1 iocb0 0000 0000 58,35 97h ? unimplemented ? ? 98h txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 142,35 99h spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 144,35 9ah ? unimplemented ? ? 9bh ? unimplemented ? ? 9ch apfcon ? ? ? ? ? ? sssel ccp2sel ---- --00 47,35 9dh fvrcon fvrrdy fvren ? ? ? ? adfvr1 adfvr0 q0-- --00 97,35 9eh ? unimplemented ? ? 9fh adcon1 ? adcs2 adcs1 adcs0 ? ? adref1 adref0 0000 --00 93,35 table 2-1: pic16f/lf722a/723a special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor page legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<12:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: accessible only when sspm<3:0> = 1001 . 4: accessible only when sspm<3:0> ? 1001 . 5: this bit is always ? 1 ? as re3 is input only.
? 2010 microchip technology inc. ds41417a-page 21 pic16f/lf722a/723a bank 2 100h (2) indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 26,34 101h tmr0 timer0 module register xxxx xxxx 99,34 102h (2) pcl program counter?s (pc) least significant byte 0000 0000 25,34 103h (2) status irp rp1 rp0 to pd zdcc 0001 1xxx 22,34 104h (2) fsr indirect data memory address pointer xxxx xxxx 26,34 105h ? unimplemented ? ? 106h ? unimplemented ? ? 107h ? unimplemented ? ? 108h cpscon0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs 0--- 0000 121,35 109h cpscon1 ? ? ? ? cpsch3 cpsch2 cpsch1 cpsch0 ---- 0000 122,35 10ah (1, 2) pclath ? ? ? write buffer for the upper 5 bits of the program counter ---0 0000 25,34 10bh (2) intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 40,34 10ch pmdatl program memory read data register low byte xxxx xxxx 177,35 10dh pmadrl program memory read address register low byte xxxx xxxx 177,35 10eh pmdath ? ? program memory read data register high byte --xx xxxx 177,35 10fh pmadrh ? ? ? program memory read address register high byte ---x xxxx 177,35 bank 3 180h (2) indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 26,34 181h option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 23,35 182h (2) pcl program counter (pc) least significant byte 0000 0000 25,34 183h (2) status irp rp1 rp0 to pd zdcc 0001 1xxx 22,34 184h (2) fsr indirect data memory address pointer xxxx xxxx 26,34 185h ansela ? ? ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 --11 1111 49,35 186h anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 --11 1111 58,35 187h ? unimplemented ? ? 18ah (1, 2) pclath ? ? ? write buffer for the upper 5 bits of the program counter ---0 0000 25,34 18bh (2) intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 40,34 18ch pmcon1 reserved ? ? ? ? ? ?rd 1--- ---0 178,35 18dh ? unimplemented ? ? 18eh ? unimplemented ? ? 18fh ? unimplemented ? ? table 2-1: pic16f/lf722a/723a special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor page legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<12:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: accessible only when sspm<3:0> = 1001 . 4: accessible only when sspm<3:0> ? 1001 . 5: this bit is always ? 1 ? as re3 is input only.
pic16f/lf722a/723a ds41417a-page 22 ? 2010 microchip technology inc. 2.2.2.1 status register the status register, shown in register 2-1, contains: ? the arithmetic status of the alu ? the reset status ? the bank select bits for data memory (sram) the status register can be the destination for any instruction, like any other register. if the status register is the destination for an instruction that affects the z, dc or c bits, then the write to these three bits is disabled. these bits are set or cleared according to the device logic. furthermore, the to and pd bits are not writable. therefore, the result of an instruction with the status register as destination may be different than intended. for example, clrf status will clear the upper three bits and set the z bit. this leaves the status register as ? 000u u1uu ? (where u = unchanged). it is recommended, therefore, that only bcf, bsf, swapf and movwf instructions are used to alter the status register, because these instructions do not affect any status bits. for other instructions not affecting any status bits (refer to section 21.0 ?instruction set summary? ). note 1: the c and dc bits operate as borrow and digit borrow out bits, respectively, in subtraction. register 2-1: status: status register r/w-0 r/w-0 r/w-0 r-1 r-1 r/w-x r/w-x r/w-x irp rp1 rp0 to pd zdc (1) c (1) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 irp: register bank select bit (used for indirect addressing) 1 = bank 2, 3 (100h-1ffh) 0 = bank 0, 1 (00h-ffh) bit 6-5 rp<1:0>: register bank select bits (used for direct addressing) 00 = bank 0 (00h-7fh) 01 = bank 1 (80h-ffh) 10 = bank 2 (100h-17fh) 11 = bank 3 (180h-1ffh) bit 4 to : time-out bit 1 = after power-up, clrwdt instruction or sleep instruction 0 = a wdt time-out occurred bit 3 pd : power-down bit 1 = after power-up or by the clrwdt instruction 0 = by execution of the sleep instruction bit 2 z: zero bit 1 = the result of an arithmetic or logic operation is zero 0 = the result of an arithmetic or logic operation is not zero bit 1 dc: digit carry/digit borrow bit ( addwf , addlw,sublw,subwf instructions) (1) 1 = a carry-out from the 4th low-order bit of the result occurred 0 = no carry-out from the 4th low-order bit of the result bit 0 c: carry/borrow bit (1) ( addwf , addlw, sublw, subwf instructions) (1) 1 = a carry-out from the most significant bit of the result occurred 0 = no carry-out from the most significant bit of the result occurred note 1: for borrow , the polarity is reversed. a subtraction is executed by adding the two?s complement of the second operand. for rotate ( rrf , rlf ) instructions, this bit is loaded with either the high-order or low-order bit of the source register.
? 2010 microchip technology inc. ds41417a-page 23 pic16f/lf722a/723a 2.2.2.2 option register the option register, shown in register 2-2, is a readable and writable register, which contains various control bits to configure: ? timer0/wdt prescaler ? external rb0/int interrupt ?timer0 ? weak pull-ups on portb note: to achieve a 1:1 prescaler assignment for timer0, assign the prescaler to the wdt by setting psa bit of the option register to ? 1 ?. refer to section 12.3 ?timer1 prescaler? . register 2-2: option_reg: option register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 rbpu intedg t0cs t0se psa ps2 ps1 ps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 rbpu : portb pull-up enable bit 1 = portb pull-ups are disabled 0 = portb pull-ups are enabled by individual bits in the wpub register bit 6 intedg: interrupt edge select bit 1 = interrupt on rising edge of rb0/int pin 0 = interrupt on falling edge of rb0/int pin bit 5 t0cs: timer0 clock source select bit 1 = transition on ra4/t0cki pin 0 = internal instruction cycle clock (f osc /4) bit 4 t0se: timer0 source edge select bit 1 = increment on high-to-low transition on ra4/t0cki pin 0 = increment on low-to-high transition on ra4/t0cki pin bit 3 psa: prescaler assignment bit 1 = prescaler is assigned to the wdt 0 = prescaler is assigned to the timer0 module bit 2-0 ps<2:0>: prescaler rate select bits 000 001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 1 : 1 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 bit value timer0 rate wdt rate
pic16f/lf722a/723a ds41417a-page 24 ? 2010 microchip technology inc. 2.2.2.3 pcon register the power control (pcon) register contains flag bits (refer to table 3-2) to differentiate between a: ? power-on reset (por ) ? brown-out reset (bor ) ? watchdog timer reset (wdt) ? external mclr reset the pcon register also controls the software enable of the bor. the pcon register bits are shown in register 2-3. register 2-3: pcon: power control register u-0 u-0 u-0 u-0 u-0 u-0 r/w-q r/w-q ? ? ? ? ? ?por bor bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown q = value depends on condition bit 7-2 unimplemented: read as ? 0 ? bit 1 por : power-on reset status bit 1 = no power-on reset occurred 0 = a power-on reset occurred (must be set in software after a power-on reset occurs) bit 0 bor : brown-out reset status bit 1 = no brown-out reset occurred 0 = a brown-out reset occurred (must be set in software after a power-on reset or brown-out reset occurs) note 1: set boren<1:0> = 01 in the configuration word register for this bit to control the bor .
? 2010 microchip technology inc. ds41417a-page 25 pic16f/lf722a/723a 2.3 pcl and pclath the program counter (pc) is 13 bits wide. the low byte comes from the pcl register, which is a readable and writable register. the high byte (pc<12:8>) is not directly readable or writable and comes from pclath. on any reset, the pc is cleared. figure 2-5 shows the two situations for the loading of the pc. the upper example in figure 2-5 shows how the pc is loaded on a write to pcl (pclath<4:0> ? pch). the lower example in figure 2-5 shows how the pc is loaded during a call or goto instruction (pclath<4:3> ? pch). figure 2-5: loading of pc in different situations 2.3.1 computed goto a computed goto is accomplished by adding an offset to the program counter ( addwf pcl ). when perform- ing a table read using a computed goto method, care should be exercised if the table location crosses a pcl memory boundary (each 256-byte block). refer to application note an556, ?implementing a table read? (ds00556). 2.3.2 stack all devices have an 8-level x 13-bit wide hardware stack (refer to figures 2-1 and 2-2). the stack space is not part of either program or data space and the stack pointer is not readable or writable. the pc is pushed onto the stack when a call instruction is executed or an interrupt causes a branch. the stack is poped in the event of a return , retlw or a retfie instruction execution. pclath is not affected by a push or pop operation. the stack operates as a circular buffer. this means that after the stack has been pushed eight times, the ninth push overwrites the value that was stored from the first push. the tenth push overwrites the second push (and so on). 2.4 program memory paging all devices are capable of addressing a continuous 8k word block of program memory. the call and goto instructions provide only 11 bits of address to allow branching within any 2k program memory page. when doing a call or goto instruction, the upper 2 bits of the address are provided by pclath<4:3>. when doing a call or goto instruction, the user must ensure that the page select bits are programmed so that the desired program memory page is addressed. if a return from a call instruction (or interrupt) is executed, the entire 13-bit pc is poped off the stack. therefore, manipulation of the pclath<4:3> bits is not required for the return instructions (which pops the address from the stack). example 2-1 shows the calling of a subroutine in page 1 of the program memory. this example assumes that pclath is saved and restored by the interrupt service routine (if interrupts are used). example 2-1: call of a subroutine in page 1 from page 0 pc 12 8 7 0 5 pclath<4:0> pclath instruction with alu result goto , call opcode<10:0> 8 pc 12 11 10 0 11 pclath<4:3> pch pcl 87 2 pclath pch pcl pcl as destination note 1: there are no status bits to indicate stack overflow or stack underflow conditions. 2: there are no instructions/mnemonics called push or pop. these are actions that occur from the execution of the call , return , retlw and retfie instruc- tions or the vectoring to an interrupt address. note: the contents of the pclath register are unchanged after a return or retfie instruction is executed. the user must rewrite the contents of the pclath regis- ter for any subsequent subroutine calls or goto instructions. org 500h pagesel sub_p1 ;select page 1 ;(800h-fffh) call sub1_p1 ;call subroutine in : ;page 1 (800h-fffh) : org 900h ;page 1 (800h-fffh) sub1_p1 : ;called subroutine ;page 1 (800h-fffh) : return ;return to ;call subroutine ;in page 0 ;(000h-7ffh)
pic16f/lf722a/723a ds41417a-page 26 ? 2010 microchip technology inc. 2.5 indirect addressing, indf and fsr registers the indf register is not a physical register. addressing the indf register will cause indirect addressing. indirect addressing is possible by using the indf register. any instruction using the indf register actually accesses data pointed to by the file select register (fsr). reading indf itself indirectly will produce 00h. writing to the indf register indirectly results in a no operation (although status bits may be affected). an effective 9-bit address is obtained by concatenating the 8-bit fsr register and the irp bit of the status register, as shown in figure 2-6. a simple program to clear ram location 020h-02fh using indirect addressing is shown in example 2-2. example 2-2: indirect addressing figure 2-6: direct/indirect addressing movlw020h ;initialize pointer movwffsr ;to ram bankisel020h nextclrfindf ;clear indf register incffsr ;inc pointer btfssfsr,4 ;all done? gotonext ;no clear next continue ;yes continue note: for memory map detail, refer to figures 2-3 and 2-4. data memory indirect addressing direct addressing bank select location select rp1 rp0 6 0 from opcode irp file select register 7 0 bank select location select 00 01 10 11 180h 1ffh 00h 7fh bank 0 bank 1 bank 2 bank 3
? 2010 microchip technology inc. ds41417a-page 27 pic16f/lf722a/723a 3.0 resets the pic16f/lf722a/723a differentiates between various kinds of reset: a) power-on reset (por) b) wdt reset during normal operation c) wdt reset during sleep d) mclr reset during normal operation e) mclr reset during sleep f) brown-out reset (bor) some registers are not affected in any reset condition; their status is unknown on por and unchanged in any other reset. most other registers are reset to a ?reset state? on: ? power-on reset (por) ?mclr reset ?mclr reset during sleep ?wdt reset ? brown-out reset (bor) most registers are not affected by a wdt wake-up since this is viewed as the resumption of normal operation. to and pd bits are set or cleared differently in different reset situations, as indicated in table 3-3. these bits are used in software to determine the nature of the reset. a simplified block diagram of the on-chip reset circuit is shown in figure 3-1. the mclr reset path has a noise filter to detect and ignore small pulses. see section 23.0 ?electrical specifications? for pulse width specifications. figure 3-1: simplified block di agram of on-chip reset circuit mclr /v pp v dd osc1/ wdt module por ost/pwrt wdtosc wdt time-out power-on reset ost 10-bit ripple counter pwrt chip_reset 11-bit ripple counter reset enable ost enable pwrt sleep brown-out (1) reset boren clkin note 1: refer to the configuration word register 1 (register 8-1). mclre
pic16f/lf722a/723a ds41417a-page 28 ? 2010 microchip technology inc. table 3-1: status bits and their significance table 3-2: reset condition for special registers (2) por bor to pd condition 0x11 power-on reset or ldo reset 0x0x illegal, to is set on por 0xx0 illegal, pd is set on por 1011 brown-out reset 1101 wdt reset 1100 wdt wake-up 11uu mclr reset during normal operation 1110 mclr reset during sleep or interrupt wake-up from sleep condition program counter status register pcon register power-on reset 0000h 0001 1xxx ---- --0x mclr reset during normal operation 0000h 000u uuuu ---- --uu mclr reset during sleep 0000h 0001 0uuu ---- --uu wdt reset 0000h 0000 1uuu ---- --uu wdt wake-up pc + 1 uuu0 0uuu ---- --uu brown-out reset 0000h 0001 1uuu ---- --u0 interrupt wake-up from sleep pc + 1 (1) uuu1 0uuu ---- --uu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?. note 1: when the wake-up is due to an interrupt and global enable bit (gie) is set, the return address is pushed on the stack and pc is loaded with the interrupt vector (0004h) after execution of pc + 1. 2: if a status bit is not implemented, that bit will be read as ? 0 ?.
? 2010 microchip technology inc. ds41417a-page 29 pic16f/lf722a/723a 3.1 mclr the pic16f/lf722a/723a has a noise filter in the mclr reset path. the filter will detect and ignore small pulses. it should be noted that a reset does not drive the mclr pin low. voltages applied to the pin that exceed its specification can result in both mclr resets and excessive current beyond the device specification during the esd event. for this reason, microchip recommends that the mclr pin no longer be tied directly to v dd . the use of an rc network, as shown in figure 3-2, is suggested. an internal mclr option is enabled by clearing the mclre bit in the configuration word register. when mclre = 0 , the reset signal to the chip is generated internally. when the mclre = 1 , the re3/mclr pin becomes an external reset input. in this mode, the re3/mclr pin has a weak pull-up to v dd . in-circuit serial programming is not affected by selecting the internal mclr option. figure 3-2: recommended mclr circuit 3.2 power-on reset (por) the on-chip por circuit holds the chip in reset until v dd has reached a high enough level for proper operation. a maximum rise time for v dd is required. see section 23.0 ?electrical specifications? for details. if the bor is enabled, the maximum rise time specification does not apply. the bor circuitry will keep the device in reset until v dd reaches v bor (see section 3.5 ?brown-out reset (bor)? ). when the device starts normal operation (exits the reset condition), device operating parameters (i.e., voltage, frequency, temperature, etc.) must be met to ensure operation. if these conditions are not met, the device must be held in reset until the operating conditions are met. for additional information, refer to application note an607, ?power-up trouble shooting? (ds00607). 3.3 power-up timer (pwrt) the power-up timer provides a fixed 64 ms (nominal) time-out on power-up only, from por or brown-out reset. the power-up timer operates from the wdt oscillator. for more information, see section 7.3 ?internal clock modes? . the chip is kept in reset as long as pwrt is active. the pwrt delay allows the v dd to rise to an acceptable level. a configuration bit, pwrte , can disable (if set) or enable (if cleared or pro- grammed) the power-up timer. the power-up timer should be enabled when brown-out reset is enabled, although it is not required. the power-up timer delay will vary from chip-to-chip and vary due to: ?v dd variation ? temperature variation ? process variation see dc parameters for details ( section 23.0 ?electrical specifications? ). 3.4 watchdog timer (wdt) the wdt has the following features: ? shares an 8-bit prescaler with timer0 ? time-out period is from 17 ms to 2.2 seconds, nominal ? enabled by a configuration bit wdt is cleared under certain conditions described in table 3-1. 3.4.1 wdt oscillator the wdt derives its time base from 31 khz internal oscillator. v dd pic ? mcu mclr r1 10 k ? c1 0.1 ? f note: the power-up timer is enabled by the pwrte bit in the configuration word. note: when the oscillator start-up timer (ost) is invoked, the wdt is held in reset, because the wdt ripple counter is used by the ost to perform the oscillator delay count. when the ost count has expired, the wdt will begin counting (if enabled).
pic16f/lf722a/723a ds41417a-page 30 ? 2010 microchip technology inc. 3.4.2 wdt control the wdte bit is located in the configuration word register 1. when set, the wdt runs continuously. the psa and ps<2:0> bits of the option register control the wdt period. see section 11.0 ?timer0 module? for more information. figure 3-1: watchdog ti mer block diagram from tmr0 postscaler 8 ps<2:0> psa to tmr0 1 1 0 0 clock source to t 1 g divide by 512 wdte tmr1ge t1gss = 11 wdte wdt reset low-power wdt osc table 3-1: wdt status conditions wdt wdte = 0 cleared clrwdt command exit sleep + system clock = t1osc, extrc, intosc, extclk exit sleep + system clock = xt, hs, lp cleared until the end of ost
? 2010 microchip technology inc. ds41417a-page 31 pic16f/lf722a/723a 3.5 brown-out reset (bor) brown-out reset is enabled by programming the boren<1:0> bits in the configuration register. the brown-out trip point is selectable from two trip points via the borv bit in the configuration register. between the por and bor, complete voltage range coverage for execution protection can be imple- mented. two bits are used to enable the bor. when boren = 11 , the bor is always enabled. when boren = 10 , the bor is enabled, but disabled during sleep. when boren = 0x , the bor is disabled. if v dd falls below v bor for greater than parameter (t bor ) (see section 23.0 ?electrical specifica- tions? ), the brown-out situation will reset the device. this will occur regardless of v dd slew rate. a reset is not ensured to occur if v dd falls below v bor for more than parameter (t bor ). if v dd drops below v bor while the power-up timer is running, the chip will go back into a brown-out reset and the power-up timer will be re-initialized. once v dd rises above v bor , the power-up timer will execute a 64 ms reset. figure 3-3: brown -out situations note: when erasing flash program memory, the bor is forced to enabled at the minimum bor setting to ensure that any code protection circuitry is operating properly. 64 ms (1) v bor v dd internal reset v bor v dd internal reset 64 ms (1) < 64 ms 64 ms (1) v bor v dd internal reset note 1: 64 ms delay only if pwrte bit is programmed to ? 0 ?.
pic16f/lf722a/723a ds41417a-page 32 ? 2010 microchip technology inc. 3.6 time-out sequence on power-up, the time-out sequence is as follows: first, pwrt time-out is invoked after por has expired, then ost is activated after the pwrt time-out has expired. the total time-out will vary based on oscillator configu- ration and pwrte bit status. for example, in ec mode with pwrte bit = 1 (pwrt disabled), there will be no time-out at all. figure 3-4, figure 3-5 and figure 3-6 depict time-out sequences. since the time-outs occur from the por pulse, if mclr is kept low long enough, the time-outs will expire. then, bringing mclr high will begin execution immediately (see figure 3-5). this is useful for testing purposes or to synchronize more than one pic16f/lf722a/723a device operating in parallel. table 3-3 shows the reset conditions for some special registers. 3.7 power control (pcon) register the power control (pcon) register has two status bits to indicate what type of reset that last occurred. bit 0 is bor (brown-out reset). bor is unknown on power-on reset. it must then be set by the user and checked on subsequent resets to see if bor = 0 , indicating that a brown-out has occurred. the bor status bit is a ?don?t care? and is not necessarily predictable if the brown-out circuit is disabled (boren<1:0> = 00 in the configuration word register). bit 1 is por (power-on reset). it is a ? 0 ? on power-on reset and unaffected otherwise. the user must write a ? 1 ? to this bit following a power-on reset. on a subsequent reset, if por is ? 0 ?, it will indicate that a power-on reset has occurred (i.e., v dd may have gone too low). for more information, see section 3.5 ?brown-out reset (bor)? . table 3-2: time-out in various situations table 3-3: reset bits and their significance oscillator configuration power-up brown-out reset wake-up from sleep pwrte = 0 pwrte = 1 pwrte = 0 pwrte = 1 xt, hs, lp (1) t pwrt + 1024 ? t osc 1024 ? t osc t pwrt + 1024 ? t osc 1024 ? t osc 1024 ? t osc rc, ec, intosc t pwrt ?t pwrt ?? note 1: lp mode with t1osc disabled. por bor to pd condition 0u11 power-on reset 1011 brown-out reset uu0u wdt reset uu00 wdt wake-up uuuu mclr reset during normal operation uu10 mclr reset during sleep legend: u = unchanged, x = unknown
? 2010 microchip technology inc. ds41417a-page 33 pic16f/lf722a/723a figure 3-4: time-out sequence on power-up (delayed mclr ): case 1 figure 3-5: time-out sequence on power-up (delayed mclr ): case 2 figure 3-6: time-out sequ ence on power-up (mclr with v dd ): case 3 t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset v dd mclr internal por pwrt time-out ost time-out internal reset t pwrt t ost t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset
pic16f/lf722a/723a ds41417a-page 34 ? 2010 microchip technology inc. table 3-4: initialization condition for registers register address power-on reset/ brown-out reset (1) mclr reset/ wdt reset wake-up from sleep through interrupt/time-out w? xxxx xxxx uuuu uuuu uuuu uuuu indf 00h/80h/ 100h/180h xxxx xxxx xxxx xxxx uuuu uuuu tmr0 01h/101h xxxx xxxx uuuu uuuu uuuu uuuu pcl 02h/82h/ 102h/182h 0000 0000 0000 0000 pc + 1 (3) status 03h/83h/ 103h/183h 0001 1xxx 000q quuu (4) uuuq quuu (4) fsr 04h/84h/ 104h/184h xxxx xxxx uuuu uuuu uuuu uuuu porta 05h xxxx xxxx xxxx xxxx uuuu uuuu portb 06h xxxx xxxx xxxx xxxx uuuu uuuu portc 07h xxxx xxxx xxxx xxxx uuuu uuuu porte 09h ---- x--- ---- x--- ---- u--- pclath 0ah/8ah/ 10ah/18ah ---0 0000 ---0 0000 ---u uuuu intcon 0bh/8bh/ 10bh/18bh 0000 000x 0000 000x uuuu uuuu (2) pir1 0ch 0000 0000 0000 0000 uuuu uuuu (2) pir2 0dh ---- ---0 ---- ---0 ---- ---u tmr1l 0eh xxxx xxxx uuuu uuuu uuuu uuuu tmr1h 0fh xxxx xxxx uuuu uuuu uuuu uuuu t1con 10h 0000 00-0 uuuu uu-u uuuu uu-u tmr2 11h 0000 0000 0000 0000 uuuu uuuu t2con 12h -000 0000 -000 0000 -uuu uuuu sspbuf 13h xxxx xxxx xxxx xxxx uuuu uuuu sspcon 14h 0000 0000 0000 0000 uuuu uuuu ccpr1l 15h xxxx xxxx xxxx xxxx uuuu uuuu ccpr1h 16h xxxx xxxx xxxx xxxx uuuu uuuu ccp1con 17h --00 0000 --00 0000 --uu uuuu rcsta 18h 0000 000x 0000 000x uuuu uuuu txreg 19h 0000 0000 0000 0000 uuuu uuuu rcreg 1ah 0000 0000 0000 0000 uuuu uuuu ccpr2l 1bh xxxx xxxx xxxx xxxx uuuu uuuu ccpr2h 1ch xxxx xxxx xxxx xxxx uuuu uuuu ccp2con 1dh --00 0000 --00 0000 --uu uuuu adres 1eh xxxx xxxx uuuu uuuu uuuu uuuu adcon0 1fh --00 0000 --00 0000 --uu uuuu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?, q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affected differently. 2: one or more bits in intcon and/or pir1 and pir2 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 3-5 for reset value for specific condition. 5: if reset was due to brown-out, then bit 0 = 0 . all other resets will cause bit 0 = u .
? 2010 microchip technology inc. ds41417a-page 35 pic16f/lf722a/723a option_reg 81h/181h 1111 1111 1111 1111 uuuu uuuu trisa 85h 1111 1111 1111 1111 uuuu uuuu trisb 86h 1111 1111 1111 1111 uuuu uuuu trisc 87h 1111 1111 1111 1111 uuuu uuuu trise 89h ---- 1--- ---- 1--- ---- u--- pie1 8ch 0000 0000 0000 0000 uuuu uuuu pie2 8dh ---- ---0 ---- ---0 ---- ---u pcon 8eh ---- --qq ---- --uu (1,5) ---- --uu t1gcon 8fh 0000 0x00 uuuu uxuu uuuu uxuu osccon 90h --10 qq-- --10 qq-- --uu qq-- osctune 91h --00 0000 --uu uuuu --uu uuuu pr2 92h 1111 1111 1111 1111 uuuu uuuu sspadd 93h 0000 0000 0000 0000 uuuu uuuu sspmsk 93h 1111 1111 1111 1111 uuuu uuuu sspstat 94h 0000 0000 0000 0000 uuuu uuuu wpub 95h 1111 1111 1111 1111 uuuu uuuu iocb 96h 0000 0000 0000 0000 uuuu uuuu txsta 98h 0000 -010 0000 -010 uuuu -uuu spbrg 99h 0000 0000 0000 0000 uuuu uuuu apfcon 9ch ---- --00 ---- --00 ---- --uu fvrcon 9dh q000 --00 q000 --00 uuuu --uu adcon1 9fh -000 --00 -000 --00 -uuu --uu cpscon0 108h 0--- 0000 0--- 0000 u--- uuuu cpscon1 109h ---- 0000 ---- 0000 ---- uuuu pmdatl 10ch xxxx xxxx xxxx xxxx uuuu uuuu pmadrl 10dh xxxx xxxx xxxx xxxx uuuu uuuu pmdath 10eh --xx xxxx --xx xxxx --uu uuuu pmadrh 10fh ---x xxxx ---x xxxx ---u uuuu ansela 185h --11 1111 --11 1111 --uu uuuu anselb 186h --11 1111 --11 1111 --uu uuuu pmcon1 18ch 1--- ---0 1--- ---0 u--- ---u table 3-4: initialization condition for registers (continued) register address power-on reset/ brown-out reset (1) mclr reset/ wdt reset wake-up from sleep through interrupt/time-out legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?, q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affected differently. 2: one or more bits in intcon and/or pir1 and pir2 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 3-5 for reset value for specific condition. 5: if reset was due to brown-out, then bit 0 = 0 . all other resets will cause bit 0 = u .
pic16f/lf722a/723a ds41417a-page 36 ? 2010 microchip technology inc. table 3-5: initialization condition for special registers table 3-6: summary of registers associated with resets condition program counter status register pcon register power-on reset 0000h 0001 1xxx ---- --0x mclr reset during normal operation 0000h 000u uuuu ---- --uu mclr reset during sleep 0000h 0001 0uuu ---- --uu wdt reset 0000h 0000 uuuu ---- --uu wdt wake-up pc + 1 uuu0 0uuu ---- --uu brown-out reset 0000h 0001 1xxx ---- --10 interrupt wake-up from sleep pc + 1 (1) uuu1 0uuu ---- --uu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?. note 1: when the wake-up is due to an interrupt and global interrupt enable bit, gie, is set, the pc is loaded with the interrupt vector (0004h) after execution of pc + 1. name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets (1) status irp rp1 rp0 to pd z dc c 0001 1xxx 000q quuu pcon ? ? ? ? ? ?por bor ---- --qq ---- --uu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?, q = value depends on condition. shaded cells are not used by resets. note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation.
? 2010 microchip technology inc. ds41417a-page 37 pic16f/lf722a/723a 4.0 interrupts the pic16f/lf722a/723a device family features an interruptible core, allowing certain events to preempt normal program flow. an interrupt service routine (isr) is used to determine the source of the interrupt and act accordingly. some interrupts can be configured to wake the mcu from sleep mode. the pic16f/lf722a/723a device family has 12 interrupt sources, differentiated by corresponding interrupt enable and flag bits: ? timer0 overflow interrupt ? external edge detect on int pin interrupt ? portb change interrupt ? timer1 gate interrupt ? a/d conversion complete interrupt ? ausart receive interrupt ? ausart transmit interrupt ? ssp event interrupt ? ccp1 event interrupt ? timer2 match with pr2 interrupt ? timer1 overflow interrupt ? ccp2 event interrupt a block diagram of the interrupt logic is shown in figure 4-1. figure 4-1: interrupt logic t0if t0ie intf inte rbif rbie gie peie wake-up (if in sleep mode) (1) interrupt to cpu tmr1gie tmr1gif adif adie ioc-rb0 iocb0 ioc-rb1 iocb1 ioc-rb2 iocb2 ioc-rb3 iocb3 ccp1if ccp1ie ioc-rb4 iocb4 ioc-rb5 iocb5 ioc-rb6 iocb6 ioc-rb7 iocb7 rcif rcie tmr2ie tmr2if sspie sspif txie txif tmr1ie tmr1if note 1: some peripherals depend upon the system clock for operation. since the system clock is suspended during sleep, these peripherals will not wake the part from sleep. see section 19.1 ?wake-up from sleep? . ccp2if ccp2ie
pic16f/lf722a/723a ds41417a-page 38 ? 2010 microchip technology inc. 4.1 operation interrupts are disabled upon any device reset. they are enabled by setting the following bits: ? gie bit of the intcon register ? interrupt enable bit(s) for the specific interrupt event(s) ? peie bit of the intcon register (if the interrupt enable bit of the interrupt event is contained in the pie1 and pie2 registers) the intcon, pir1 and pir2 registers record individ- ual interrupts via interrupt flag bits. interrupt flag bits will be set, regardless of the status of the gie, peie and individual interrupt enable bits. the following events happen when an interrupt event occurs while the gie bit is set: ? current prefetched instruction is flushed ? gie bit is cleared ? current program counter (pc) is pushed onto the stack ? pc is loaded with the interrupt vector 0004h the isr determines the source of the interrupt by polling the interrupt flag bits. the interrupt flag bits must be cleared before exiting the isr to avoid repeated interrupts. because the gie bit is cleared, any interrupt that occurs while executing the isr will be recorded through its interrupt flag, but will not cause the processor to redirect to the interrupt vector. the retfie instruction exits the isr by popping the previous address from the stack and setting the gie bit. for additional information on a specific interrupt?s operation, refer to its peripheral chapter. 4.2 interrupt latency interrupt latency is defined as the time from when the interrupt event occurs to the time code execution at the interrupt vector begins. the latency for synchronous interrupts is 3 instruction cycles. for asynchronous interrupts, the latency is 3 to 4 instruction cycles, depending on when the interrupt occurs. see figure 4-2 for timing details. figure 4-2: int pin interrupt timing note 1: individual interrupt flag bits are set, regardless of the state of any other enable bits. 2: all interrupts will be ignored while the gie bit is cleared. any interrupt occurring while the gie bit is clear will be serviced when the gie bit is set again. q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 osc1 clkout int pin intf flag (intcon<1>) gie bit (intcon<7>) instruction flow pc instruction fetched instruction executed interrupt latency pc pc + 1 pc + 1 0004h 0005h inst (0004h) inst (0005h) dummy cycle inst (pc) inst (pc + 1) inst (pc ? 1) inst (0004h) dummy cycle inst (pc) ? note 1: intf flag is sampled here (every q1). 2: asynchronous interrupt latency = 3-4 t cy . synchronous latency = 3 t cy , where t cy = instruction cycle time. latency is the same whether inst (pc) is a single cycle or a 2-cycle instruction. 3: clkout is available only in intosc and rc oscillator modes. 4: for minimum width of int pulse, refer to ac specifications in section 23.0 ?electrical specifications? . 5: intf is enabled to be set any time during the q4-q1 cycles. (1) (2) (3) (4) (5) (1)
? 2010 microchip technology inc. ds41417a-page 39 pic16f/lf722a/723a 4.3 interrupts during sleep some interrupts can be used to wake from sleep. to wake from sleep, the peripheral must be able to operate without the system clock. the interrupt source must have the appropriate interrupt enable bit(s) set prior to entering sleep. on waking from sleep, if the gie bit is also set, the processor will branch to the interrupt vector. otherwise, the processor will continue executing instructions after the sleep instruction. the instruction directly after the sleep instruction will always be executed before branching to the isr. refer to section 19.0 ?power- down mode (sleep)? for more details. 4.4 int pin the external interrupt, int pin, causes an asynchronous, edge-triggered interrupt. the intedg bit of the option register determines on which edge the interrupt will occur. when the intedg bit is set, the rising edge will cause the interrupt. when the intedg bit is clear, the falling edge will cause the interrupt. the intf bit of the intcon register will be set when a valid edge appears on the int pin. if the gie and inte bits are also set, the processor will redirect program execution to the interrupt vector. this interrupt is disabled by clearing the inte bit of the intcon register. 4.5 context saving when an interrupt occurs, only the return pc value is saved to the stack. if the isr modifies or uses an instruction that modifies key registers, their values must be saved at the beginning of the isr and restored when the isr completes. this prevents instructions following the isr from using invalid data. examples of key registers include the w, status, fsr and pclath registers. the code shown in example 4-1 can be used to do the following. ? save the w register ? save the status register ? save the pclath register ? execute the isr program ? restore the pclath register ? restore the status register ? restore the w register since most instructions modify the w register, it must be saved immediately upon entering the isr. the swapf instruction is used when saving and restoring the w and status registers because it will not affect any bits in the status register. it is useful to place w_temp in shared memory because the isr cannot predict which bank will be selected when the interrupt occurs. the processor will branch to the interrupt vector by loading the pc with 0004h. the pclath register will remain unchanged. this requires the isr to ensure that the pclath register is set properly before using an instruction that causes pclath to be loaded into the pc. see section 2.3 ?pcl and pclath? for details on pc operation. example 4-1: saving w, status and pclath registers in ram note: the microcontroller does not normally require saving the pclath register. however, if computed goto ?s are used, the pclath register must be saved at the beginning of the isr and restored when the isr is complete to ensure correct program flow. movwfw_temp ;copy w to w_temp register swapfstatus,w ;swap status to be saved into w ;swaps are used because they do not affect the status bits bankselstatus_temp ;select regardless of current bank movwfstatus_temp ;copy status to bank zero status_temp register movf pclath,w ;copy pclath to w register movwf pclath_temp ;copy w register to pclath_temp : :(isr) ;insert user code here : bankselstatus_temp ;select regardless of current bank movf pclath_temp,w ; movwf pclath ;restore pclath swapfstatus_temp,w ;swap status_temp register into w ;(sets bank to original state) movwfstatus ;move w into status register swapfw_temp,f ;swap w_temp swapfw_temp,w ;swap w_temp into w
pic16f/lf722a/723a ds41417a-page 40 ? 2010 microchip technology inc. 4.5.1 intcon register the intcon register is a readable and writable register, which contains the various enable and flag bits for tmr0 register overflow, portb change and external rb0/int/seg0 pin interrupts. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie of the intcon register. user software should ensure the appropri- ate interrupt flag bits are clear prior to enabling an interrupt. register 4-1: intcon: interrupt control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-x gie peie t0ie inte rbie (1) t0if (2) intf rbif bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 gie: global interrupt enable bit 1 = enables all unmasked interrupts 0 = disables all interrupts bit 6 peie: peripheral interrupt enable bit 1 = enables all unmasked peripheral interrupts 0 = disables all peripheral interrupts bit 5 t0ie: timer0 overflow interrupt enable bit 1 = enables the timer0 interrupt 0 = disables the timer0 interrupt bit 4 inte: rb0/int external interrupt enable bit 1 = enables the rb0/int external interrupt 0 = disables the rb0/int external interrupt bit 3 rbie: portb change interrupt enable bit (1) 1 = enables the portb change interrupt 0 = disables the portb change interrupt bit 2 t0if: timer0 overflow interrupt flag bit (2) 1 = tmr0 register has overflowed (must be cleared in software) 0 = tmr0 register did not overflow bit 1 intf: rb0/int external interrupt flag bit 1 = the rb0/int external interrupt occurred (must be cleared in software) 0 = the rb0/int external interrupt did not occur bit 0 rbif: portb change interrupt flag bit 1 = when at least one of the portb general purpose i/o pins changed state (must be cleared in software) 0 = none of the portb general purpose i/o pins have changed state note 1: the appropriate bits in the iocb register must also be set. 2: t0if bit is set when timer0 rolls over. timer0 is unchanged on reset and should be initialized before clearing t0if bit.
? 2010 microchip technology inc. ds41417a-page 41 pic16f/lf722a/723a 4.5.2 pie1 register the pie1 register contains the interrupt enable bits, as shown in register 4-2. note: bit peie of the intcon register must be set to enable any peripheral interrupt. register 4-2: pie1: peripheral interrupt enable register 1 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 tmr1gie: timer1 gate interrupt enable bit 1 = enable the timer1 gate acquisition complete interrupt 0 = disable the timer1 gate acquisition complete interrupt bit 6 adie: a/d converter (adc) interrupt enable bit 1 = enables the adc interrupt 0 = disables the adc interrupt bit 5 rcie: usart receive interrupt enable bit 1 = enables the usart receive interrupt 0 = disables the usart receive interrupt bit 4 txie: usart transmit interrupt enable bit 1 = enables the usart transmit interrupt 0 = disables the usart transmit interrupt bit 3 sspie: synchronous serial port (ssp) interrupt enable bit 1 = enables the ssp interrupt 0 = disables the ssp interrupt bit 2 ccp1ie: ccp1 interrupt enable bit 1 = enables the ccp1 interrupt 0 = disables the ccp1 interrupt bit 1 tmr2ie: tmr2 to pr2 match interrupt enable bit 1 = enables the timer2 to pr2 match interrupt 0 = disables the timer2 to pr2 match interrupt bit 0 tmr1ie: timer1 overflow interrupt enable bit 1 = enables the timer1 overflow interrupt 0 = disables the timer1 overflow interrupt
pic16f/lf722a/723a ds41417a-page 42 ? 2010 microchip technology inc. 4.5.3 pie2 register the pie2 register contains the interrupt enable bits, as shown in register 4-3. note: bit peie of the intcon register must be set to enable any peripheral interrupt. register 4-3: pie2: peripheral interrupt enable register 2 u-0 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0 ? ? ? ? ? ? ? ccp2ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-1 unimplemented: read as ? 0 ? bit 0 ccp2ie: ccp2 interrupt enable bit 1 = enables the ccp2 interrupt 0 = disables the ccp2 interrupt
? 2010 microchip technology inc. ds41417a-page 43 pic16f/lf722a/723a 4.5.4 pir1 register the pir1 register contains the interrupt flag bits, as shown in register 4-4. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie of the intcon register. user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. register 4-4: pir1: peripheral interrupt request register 1 r/w-0 r/w-0 r-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 tmr1gif: timer1 gate interrupt flag bit 1 = timer1 gate is inactive 0 = timer1 gate is active bit 6 adif: a/d converter interrupt flag bit 1 = a/d conversion complete (must be cleared in software) 0 = a/d conversion has not completed or has not been started bit 5 rcif: usart receive interrupt flag bit 1 = the usart receive buffer is full (cleared by reading rcreg) 0 = the usart receive buffer is not full bit 4 txif: usart transmit interrupt flag bit 1 = the usart transmit buffer is empty (cleared by writing to txreg) 0 = the usart transmit buffer is full bit 3 sspif: synchronous serial port (ssp) interrupt flag bit 1 = the transmission/reception is complete (must be cleared in software) 0 = waiting to transmit/receive bit 2 ccp1if: ccp1 interrupt flag bit capture mode : 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode : 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode : unused in this mode bit 1 tmr2if: timer2 to pr2 interrupt flag bit 1 = a timer2 to pr2 match occurred (must be cleared in software) 0 = no timer2 to pr2 match occurred bit 0 tmr1if: timer1 overflow interrupt flag bit 1 = the tmr1 register overflowed (must be cleared in software) 0 = the tmr1 register did not overflow
pic16f/lf722a/723a ds41417a-page 44 ? 2010 microchip technology inc. 4.5.5 pir2 register the pir2 register contains the interrupt flag bits, as shown in register 4-5. table 4-1: summary of register s associated with interrupts note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie of the intcon register. user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. register 4-5: pir2: peripheral interrupt request register 2 u-0 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0 ? ? ? ? ? ? ? ccp2if bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-1 unimplemented: read as ? 0 ? bit 0 ccp2if: ccp2 interrupt flag bit capture mode : 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode : 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode : unused in this mode name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pie2 ? ? ? ? ? ? ?ccp2ie ---- ---0 ---- ---0 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pir2 ? ? ? ? ? ? ? ccp2if ---- ---0 ---- ---0 legend: - = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the capture, compare and pwm.
? 2010 microchip technology inc. ds41417a-page 45 pic16f/lf722a/723a 5.0 low dropout (ldo) voltage regulator the pic16f722a/723a devices differ from the pic16lf722a/723a devices due to an internal low dropout (ldo) voltage regulator. the pic16f722a/ 723a contain an internal ldo, while the pic16lf722a/ 723a do not. the lithography of the die allows a maximum operating voltage of 3.6v on the internal digital logic. in order to continue to support 5.0v designs, a ldo voltage regulator is integrated on the die. the ldo voltage regulator allows for the internal digital logic to operate at 3.2v, while i/o?s operate at 5.0v (v dd ). the ldo voltage regulator requires an external bypass capacitor for stability. one of three pins, denoted as v cap , can be configured for the external bypass capacitor. it is recommended that the capacitor be a ceramic cap between 0.1 to 1.0 f. the v cap pin is not intended to supply power to external loads. an external voltage regulator should be used if this functionality is required. in addition, external devices should not supply power to the v cap pin. on power-up, the external capacitor will look like a large load on the ldo voltage regulator. to prevent erroneous operation, the device is held in reset while a constant current source charges the external capacitor. after the cap is fully charged, the device is released from reset. for more information, refer to section 23.0 ?electrical specifications? . see configuration word 2 register (register 8-2) for v cap enable bits.
pic16f/lf722a/723a ds41417a-page 46 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 47 pic16f/lf722a/723a 6.0 i/o ports there are as many as thirty-five general purpose i/o pins available. depending on which peripherals are enabled, some or all of the pins may not be available as general purpose i/o. in general, when a peripheral is enabled, the associated pin may not be used as a general purpose i/o pin. 6.1 alternate pin function the alternate pin function control (apfcon) register is used to steer specific peripheral input and output functions between different pins. the apfcon register is shown in register 6-1. for this device family, the following functions can be moved between different pins: ?ss (slave select) ? ccp2 register 6-1: apfcon: alternate pin function co ntrol register u-0 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 ? ? ? ? ? ? sssel ccp2sel bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-2 unimplemented: read as ? 0 ?. bit 1 sssel: ss input pin selection bit 0 =ss function is on ra5/an4/cps7/ss /v cap 1 =ss function is on ra0/an0/ss /v cap bit 0 ccp2sel: ccp2 input/output pin selection bit 0 = ccp2 function is on rc1/t1osi/ccp2 1 = ccp2 function is on rb3/ccp2
pic16f/lf722a/723a ds41417a-page 48 ? 2010 microchip technology inc. 6.2 porta and the trisa registers porta is a 8-bit wide, bidirectional port. the corresponding data direction register is trisa (register 6-3). setting a trisa bit (= 1 ) will make the corresponding porta pin an input (i.e., disable the output driver). clearing a trisa bit (= 0 ) will make the corresponding porta pin an output (i.e., enables output driver and puts the contents of the output latch on the selected pin). example 6-1 shows how to initialize porta. reading the porta register (register 6-2) reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. therefore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch. the trisa register (register 6-3) controls the porta pin output drivers, even when they are being used as analog inputs. the user should ensure the bits in the trisa register are maintained set when using them as analog inputs. i/o pins configured as analog input always read ? 0 ?. example 6-1: initializing porta note: the ansela register must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. banksel porta ; clrf porta ;init porta banksel ansela ; clrf ansela ;digital i/o banksel trisa ; movlw 0ch ;set ra<3:2> as inputs movwf trisa ;and set ra<7:4,1:0> ;as outputs register 6-2: porta: porta register r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 ra<7:0> : porta i/o pin bit 1 = port pin is > v ih 0 = port pin is < v il register 6-3: trisa: porta tri-state register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 trisa<7:0>: porta tri-state control bit 1 = porta pin configured as an input (tri-stated) 0 = porta pin configured as an output
? 2010 microchip technology inc. ds41417a-page 49 pic16f/lf722a/723a 6.2.1 ansela register the ansela register (register 6-4) is used to configure the input mode of an i/o pin to analog. setting the appropriate ansela bit high will cause all digital reads on the pin to be read as ? 0 ? and allow analog functions on the pin to operate correctly. the state of the ansela bits has no affect on digital output functions. a pin with tris clear and ansel set will still operate as a digital output, but the input mode will be analog. this can cause unexpected behavior when executing read-modify-write instructions on the affected port. register 6-4: ansela: porta analog select register u-0 u-0 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 ? ? ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5-0 ansa<5:0> : analog select between analog or digital function on pins ra<5:0>, respectively 0 = digital i/o. pin is assigned to port or digital special function. 1 = analog input. pin is assigned as analog input (1) . digital input buffer disabled. note 1: when setting a pin to an analog input, the corresponding tris bit must be set to input mode in order to allow external control of the voltage on the pin.
pic16f/lf722a/723a ds41417a-page 50 ? 2010 microchip technology inc. 6.2.2 pin descriptions and diagrams each porta pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions such as the a/d conver ter (adc), refer to the appropriate section in this data sheet. 6.2.2.1 ra0/an0/ss /v cap figure 6-1 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc ? slave select input for the ssp (1) ? voltage regulator capacitor pin (pic16f722a/ 723a only) 6.2.2.2 ra1/an1 figure 6-2 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc 6.2.2.3 ra2/an2 figure 6-2 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc 6.2.2.4 ra3/an3/v ref figure 6-2 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc ? voltage reference input for the adc 6.2.2.5 ra4/cps6/t0cki figure 6-3 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? capacitive sensing input ? clock input for timer0 the timer0 clock input function works independently of any tris register setting. effectively, if trisa4 = 0 , the porta4 register bit will output to the pad and clock timer0 at the same time. 6.2.2.6 ra5/an4/cps7/ss /v cap figure 6-4 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc ? capacitive sensing input ? slave select input for the ssp (1) ? voltage regulator capacitor pin (pic16f722a/ 723a only) 6.2.2.7 ra6/osc2/clkout/v cap figure 6-5 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? crystal/resonator connection ? clock output ? voltage regulator capacitor pin (pic16f722a/ 723a only) 6.2.2.8 ra7/osc1/clkin figure 6-6 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? crystal/resonator connection ? clock input note 1: ss pin location may be selected as ra5 or ra0. note 1: ss pin location may be selected as ra5 or ra0.
? 2010 microchip technology inc. ds41417a-page 51 pic16f/lf722a/723a figure 6-1: blo ck diagram of ra0 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd ansa0 data bus porta trisa trisa porta to ssp ss input to a/d converter vcapen = 00 to voltage regulator pic16f722a/723a only
pic16f/lf722a/723a ds41417a-page 52 ? 2010 microchip technology inc. figure 6-2: ra<3:1> block diagram figure 6-3: blo ck diagram of ra4 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd ansax data bus porta trisa trisa porta to a/d converter i/o pin v dd v ss d q ck q d q ck q rd wr wr rd ansa4 data bus porta trisa trisa porta to timer0 clock mux to cap sensor
? 2010 microchip technology inc. ds41417a-page 53 pic16f/lf722a/723a figure 6-4: blo ck diagram of ra5 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd ansa5 data bus porta trisa trisa porta to ssp ss input to a/d converter vcapen = 01 to voltage regulator pic16f722a/723a only to cap sensor
pic16f/lf722a/723a ds41417a-page 54 ? 2010 microchip technology inc. figure 6-5: blo ck diagram of ra6 figure 6-6: blo ck diagram of ra7 0 1 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd f osc = lp or xt or hs data bus porta trisa trisa porta f osc /4 clkout(1) enable note 1: clkout enable = 1 when f osc = rc or intosc (no i/o selected). oscillator circuit ra7/osc1 vcapen = 10 to voltage regulator ( 00 x or 010 ) pic16f722a/723a only i/o pin v dd v ss d q ck q d q ck q rd wr wr rd osc = intosc or data bus porta trisa trisa porta oscillator circuit ra6/osc2 intoscio
? 2010 microchip technology inc. ds41417a-page 55 pic16f/lf722a/723a table 6-1: summary of regist ers associated with porta name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets adcon0 ? ? chs3 chs2 chs1 chs0 go/done adon 0000 0000 0000 0000 adcon1 ? adcs2 adcs1 adcs0 ? ? adref1 adref0 -000 --00 -000 --00 ansela ? ? ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 --11 1111 --11 1111 apfcon ? ? ? ? ? ? sssel ccp2sel ---- --00 ---- --00 cpscon0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs 0--- 0000 0--- 0000 cpscon1 ? ? ? ? cpsch3 cpsch2 cpsch1 cpsch0 ---- 0000 ---- 0000 config2 (1) ? ? vcapen1 vcapen0 ? ? ? ? ?? option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 porta ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 xxxx xxxx xxxx xxxx sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by porta. note 1: pic16f722a/723a only.
pic16f/lf722a/723a ds41417a-page 56 ? 2010 microchip technology inc. 6.3 portb and trisb registers portb is an 8-bit wide, bidirectional port. the corresponding data direction register is trisb (register 6-6). setting a trisb bit (= 1 ) will make the corresponding portb pin an input (i.e., put the corresponding output driver in a high-impedance mode). clearing a trisb bit (= 0 ) will make the corresponding portb pin an output (i.e., enable the output driver and put the contents of the output latch on the selected pin). example 6-2 shows how to initialize portb. reading the portb register (register 6-5) reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. therefore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch. the trisb register (register 6-6) controls the portb pin output drivers, even when they are being used as analog inputs. the user should ensure the bits in the trisb register are maintained set when using them as analog inputs. i/o pins configured as analog input always read ? 0 ?. example 6-2 shows how to initialize portb. example 6-2: initializing portb 6.3.1 anselb register the anselb register (register 6-9) is used to configure the input mode of an i/o pin to analog. setting the appropriate anselb bit high will cause all digital reads on the pin to be read as ? 0 ? and allow analog functions on the pin to operate correctly. the state of the anselb bits has no affect on digital output functions. a pin with tris clear and anselb set will still operate as a digital output, but the input mode will be analog. this can cause unexpected behavior when executing read-modify-write instructions on the affected port. 6.3.2 weak pull-ups each of the portb pins has an individually configurable internal weak pull-up. control bits wpub<7:0> enable or disable each pull-up (see register 6-7). each weak pull- up is automatically turned off when the port pin is configured as an output. all pull-ups are disabled on a power-on reset by the rbpu bit of the option register. 6.3.3 interrupt-on-change all of the portb pins are individually configurable as an interrupt-on-change pin. control bits iocb<7:0> enable or disable the interrupt function for each pin. refer to register 6-8. the interr upt-on-change feature is disabled on a power-on reset. for enabled interrupt-on-change pins, the present value is compared with the old value latched on the last read of portb to determine which bits have changed or mismatched the old value. the ?mismatch? outputs of the last read are or?d together to set the portb change interrupt flag bit (rbif) in the intcon register. this interrupt can wake the device from sleep. the user, in the interrupt service routine, clears the interrupt by: a) any read or write of portb. this will end the mismatch condition. b) clear the flag bit rbif. a mismatch condition will continue to set flag bit rbif. reading or writing portb will end the mismatch condition and allow flag bit rbif to be cleared. the latch holding the last read value is not affected by a mclr nor brown-out reset. after these resets, the rbif flag will continue to be set if a mismatch is present. note: the anselb register must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. banksel portb ; clrf portb ;init portb banksel anselb clrf anselb ;make rb<7:0> digital banksel trisb ; movlw b ? 11110000 ? ;set rb<7:4> as inputs ;and rb<3:0> as outputs movwf trisb ; note: when a pin change occurs at the same time as a read operation on portb, the rbif flag will always be set. if multiple portb pins are configured for the interrupt-on-change, the user may not be able to identify which pin changed state.
? 2010 microchip technology inc. ds41417a-page 57 pic16f/lf722a/723a register 6-5: port b: portb register r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 rb<7:0> : portb i/o pin bits 1 = port pin is > v ih 0 = port pin is < v il register 6-6: trisb: po rtb tri-state register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 trisb<7:0>: portb tri-state control bits 1 = portb pin configured as an input (tri-stated) 0 = portb pin configured as an output register 6-7: wpub: weak pull-up portb register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 wpub7 wpub6 wpub5 wpub4 wpub3 wpub2 wpub1 wpub0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 wpub<7:0> : weak pull-up register bits 1 = pull-up enabled 0 = pull-up disabled note 1: global rbpu bit of the option register must be cleared for individual pull-ups to be enabled. 2: the weak pull-up device is automatically disabled if the pin is in configured as an output.
pic16f/lf722a/723a ds41417a-page 58 ? 2010 microchip technology inc. register 6-8: iocb: interrup t-on-change portb register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 iocb7 iocb6 iocb5 iocb4 iocb3 iocb2 iocb1 iocb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 iocb<7:0>: interrupt-on-change portb control bits 1 = interrupt-on-change enabled 0 = interrupt-on-change disabled register 6-9: anselb: portb analog select register u-0 u-0 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5-0 ansb<5:0> : analog select between analog or digital function on pins rb<5:0>, respectively 0 = digital i/o. pin is assigned to port or digital special function. 1 = analog input. pin is assigned as analog input (1) . digital input buffer disabled. note 1: when setting a pin to an analog input, the corresponding tris bit must be set to input mode in order to allow external control of the voltage on the pin.
? 2010 microchip technology inc. ds41417a-page 59 pic16f/lf722a/723a 6.3.4 pin descriptions and diagrams each portb pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions such as the ssp, i 2 c or interrupts, refer to the appropriate section in this data sheet. 6.3.4.1 rb0/an12/cps0/int figure 6-7 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc ? capacitive sensing input ? external edge triggered interrupt 6.3.4.2 rb1/an10/cps1 figure 6-8 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc ? capacitive sensing input 6.3.4.3 rb2/an8/cps2 figure 6-8 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc ? capacitive sensing input 6.3.4.4 rb3/an9/cps3/ccp2 figure 6-9 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc ? capacitive sensing input ? capture 2 input, compare 2 output, and pwm2 output 6.3.4.5 rb4/an11/cps4 figure 6-8 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc ? capacitive sensing input 6.3.4.6 rb5/an13/cps5/t1g figure 6-10 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? analog input for the adc ? capacitive sensing input ? timer1 gate input 6.3.4.7 rb6/icspclk figure 6-11 shows the diagram for this pin. this pin is configurable to function as one of the following: ? a general purpose i/o ? in-circuit serial programming clock 6.3.4.8 rb7/icspdat figure 6-12 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? in-circuit serial programming data note: ccp2 pin location may be selected as rb3 or rc1.
pic16f/lf722a/723a ds41417a-page 60 ? 2010 microchip technology inc. figure 6-7: blo ck diagram of rb0 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portb trisb trisb portb d q ck q v dd weak wr wpub rd wpub rbpu d q ck q d en q d en q rd portb wr iocb rd iocb interrupt-on- change q3 ansb0 to a/d converter to external interrupt logic to cap sensor
? 2010 microchip technology inc. ds41417a-page 61 pic16f/lf722a/723a figure 6-8: block di agram of rb4, rb<2:1> i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portb trisb trisb portb d q ck q v dd weak wr wpub rd wpub rbpu d q ck q d en q d en q rd portb wr iocb rd iocb interrupt-on- change q3 ansb<4,2,1> to a / d c o n v e r t e r to cap sensor
pic16f/lf722a/723a ds41417a-page 62 ? 2010 microchip technology inc. figure 6-9: blo ck diagram of rb3 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portb trisb trisb portb d q ck q v dd weak wr wpub rd wpub rbpu d q ck q d en q d en q rd portb wr iocb rd iocb interrupt-on- change q3 ansb<5,3> to ccp2 (1) note 1: ccp2 input is controlled by ccp2sel in the apfcon register. 0 1 ccp2out ccp2out enable to a/d converter to cap sensor
? 2010 microchip technology inc. ds41417a-page 63 pic16f/lf722a/723a figure 6-10: blo ck diagram of rb5 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portb trisb trisb portb d q ck q v dd weak wr wpub rd wpub rbpu d q ck q d en q d en q rd portb wr iocb rd iocb interrupt-on- change q3 ansb<5,3> to timer1 gate 0 1 ccp2out ccp2out enable to a/d converter to cap sensor
pic16f/lf722a/723a ds41417a-page 64 ? 2010 microchip technology inc. figure 6-11: block diagram of rb6 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portb trisb trisb portb d q ck q v dd weak wr wpub rd wpub rbpu d q ck q d en q d en q rd portb wr iocb rd iocb interrupt-on- change q3 icsp? mode icspclk 0 1 0 1 tris_icdclk port_icdclk debug
? 2010 microchip technology inc. ds41417a-page 65 pic16f/lf722a/723a figure 6-12: blo ck diagram of rb7 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portb trisb trisb portb d q ck q v dd weak wr wpub rd wpub rbpu d q ck q d en q d en q rd portb wr iocb rd iocb interrupt-on- change q3 icspdat_in 0 1 0 1 tris_icddat port_icddat icsp? mode debug
pic16f/lf722a/723a ds41417a-page 66 ? 2010 microchip technology inc. table 6-2: summary of registers associated with portb name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets adcon0 ? ? chs3 chs2 chs1 chs0 go/done adon --00 0000 --00 0000 anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 --11 1111 --11 1111 apfcon ? ? ? ? ? ? sssel ccp2sel ---- --00 ---- --00 ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 --00 0000 cpscon0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs 0--- 0000 0--- 0000 cpscon1 ? ? ? ? cpsch3 cpsch2 cpsch1 cpsch0 ---- 0000 ---- 0000 intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x iocb iocb7 iocb6 iocb5 iocb4 iocb3 iocb2 iocb1 iocb0 0000 0000 0000 0000 option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx xxxx xxxx xxxx t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/ done t1gval t1gss1 t1gss0 0000 0x00 uuuu uxuu trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 wpub wpub7 wpub6 wpub5 wpub4 wpub3 wpub2 wpub1 wpub0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by portb.
? 2010 microchip technology inc. ds41417a-page 67 pic16f/lf722a/723a 6.4 portc and trisc registers portc is a 8-bit wide, bidirectional port. the corresponding data direction register is trisc (register 6-11). setting a trisc bit (= 1 ) will make the corresponding portc pin an input (i.e., put the corresponding output driver in a high-impedance mode). clearing a trisc bit (= 0 ) will make the corresponding portc pin an output (i.e., enable the output driver and put the contents of the output latch on the selected pin). example 6-3 shows how to initialize portc. reading the portc register (register 6-10) reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. therefore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch. the trisc register (register 6-11) controls the portc pin output drivers, even when they are being used as analog inputs. the user should ensure the bits in the trisc register are maintained set when using them as analog inputs. i/o pins configured as analog input always read ? 0 ?. example 6-3: initializing portc the location of the ccp2 function is controlled by the ccp2sel bit in the apfcon register (refer to register 6-1). banksel portc ; clrf portc ;init portc banksel trisc ; movlw b?00001100? ;set rc<3:2> as inputs movwf trisc ;and set rc<7:4,1:0> ;as outputs register 6-10: port c: portc register r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 rc<7:0> : portc general purpose i/o pin bits 1 = port pin is > v ih 0 = port pin is < v il register 6-11: trisc: po rtc tri-state register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 trisc<7:0>: portc tri-state control bits 1 = portc pin configured as an input (tri-stated) 0 = portc pin configured as an output
pic16f/lf722a/723a ds41417a-page 68 ? 2010 microchip technology inc. 6.4.1 rc0/t1oso/t1cki figure 6-13 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? timer1 oscillator output ? timer1 clock input 6.4.2 rc1/t1osi/ccp2 figure 6-14 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? timer1 oscillator input ? capture 2 input, compare 2 output, and pwm2 output 6.4.3 rc2/ccp1 figure 6-15 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? capture 1 input, compare 1 output, and pwm1 output 6.4.4 rc3/sck/scl figure 6-16 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? spi clock ?i 2 c? clock 6.4.5 rc4/sdi/sda figure 6-17 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? spi data input ?i 2 c data i/o 6.4.6 rc5/sdo figure 6-18 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? spi data output 6.4.7 rc6/tx/ck figure 6-19 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? asynchronous serial output ? synchronous clock i/o 6.4.8 rc7/rx/dt figure 6-20 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose i/o ? asynchronous serial input ? synchronous serial data i/o note: ccp2 pin location may be selected as rb3 or rc1.
? 2010 microchip technology inc. ds41417a-page 69 pic16f/lf722a/723a figure 6-13: blo ck diagram of rc0 figure 6-14: blo ck diagram of rc1 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd t1oscen data bus portc trisc trisc portc to timer1 clk input oscillator circuit rc1/t1osi 0 1 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd t1oscen data bus portc trisc trisc portc to ccp2 (1) input ccp2out ccp2out enable oscillator circuit rc0/t1oso note 1: ccp2 input is controlled by ccp2sel in the apfcon register.
pic16f/lf722a/723a ds41417a-page 70 ? 2010 microchip technology inc. figure 6-15: blo ck diagram of rc2 figure 6-16: blo ck diagram of rc3 0 1 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portc trisc trisc portc to ccp1 input ccp1out ccp1out enable i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portc trisc trisc portc to ssp spi 0 1 sspen sspm = i 2 c? mode scl sspen 0 1 sck_master sspm = spi mode to ssp i 2 c? clock input scl input 0 1 1 0 (2) i 2 c ? (1) note 1: i 2 c ? schmitt trigger has special input levels. 2: i 2 c ? slew rate limiting controlled by smp bit of sspstat register.
? 2010 microchip technology inc. ds41417a-page 71 pic16f/lf722a/723a figure 6-17: block diagram of rc4 figure 6-18: block diagram of rc5 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portc trisc trisc portc to ssp spi 0 1 sspen sspm = i 2 c? mode sda from ssp to ssp i 2 c ? i 2 c ? (1) sda input 0 1 1 0 data input (2) note 1: i 2 c ? schmitt trigger has special input levels. 2: i 2 c ? slew rate limiting controlled by smp bit of sspstat register. 0 1 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portc trisc trisc portc sdo sspen sspm = spi mode sdo en
pic16f/lf722a/723a ds41417a-page 72 ? 2010 microchip technology inc. figure 6-19: block diagram of rc6 figure 6-20: block diagram of rc7 i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portc trisc trisc portc to usart 0 1 spen 0 1 usart_tx sync usart_ck 0 1 txen sync csrc sync clock input i/o pin v dd v ss d q ck q d q ck q rd wr wr rd data bus portc trisc trisc portc to usart data input 0 1 spen sync usart_dt spen sync txen sren cren
? 2010 microchip technology inc. ds41417a-page 73 pic16f/lf722a/723a table 6-3: summary of regist ers associated with portc name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets apfcon ? ? ? ? ? ? sssel ccp2sel ---- --00 ---- --00 ccp1con ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 --00 0000 ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 --00 0000 portc rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 xxxx xxxx xxxx xxxx rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 sspstat smp cke d/a p s r/w ua bf 0000 0000 0000 0000 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ? tmr1on 0000 00 - 0 uuuu uu - u txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 0000 -010 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by portb.
pic16f/lf722a/723a ds41417a-page 74 ? 2010 microchip technology inc. 6.5 porte and trise registers porte (1) is an 1-bit wide, input only port. re3 is input only and its tris bit will always read as ? 1 ?. reading the porte register (register 6-12) reads the status of the pins. re3 reads ? 0 ? when mclre = 1. table 6-4: summary of registers associated with porte register 6-12: port e: porte register u-0 u-0 u-0 u-0 r-x u-0 u-0 u-0 ? ? ? ? re3 ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-4 unimplemented : read as ? 0 ? bit 3 re3 : porte i/o pin bits (1) 1 = port pin is > v ih 0 = port pin is < v il bit 2-0 unimplemented : read as ? 0 ? register 6-13: trise: porte tri-state register u-0 u-0 u-0 u-0 r-1 u-0 u-0 u-0 ? ? ? ? trise3 ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-4 unimplemented : read as ? 0 ? bit 3 trise3: re3 port tri-state control bit this bit is always ? 1 ? as re3 is an input only bit 2-0 unimplemented : read as ? 0 ? name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets porte????re3 ? ? ? ---- x--- ---- x--- trise ? ? ? ?trise3 (1) ? ? ? ---- 1--- ---- 1--- legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by porte note 1: this bit is always ? 1 ? as re3 is input only.
? 2010 microchip technology inc. ds41417a-page 75 pic16f/lf722a/723a 6.5.1 re3/mclr /v pp figure 6-21 shows the diagram for this pin. this pin is configurable to function as one of the following: ? general purpose input ? master clear reset with weak pull-up ? programming voltage reference input figure 6-21: block diagram of re3 i/o pin v ss rd rd data bus trise porte v ss high-voltage detect in-circuit serial programming? mode pulse filter mclr mclr circuit power for programming flash v dd weak icsp? mode detect
pic16f/lf722a/723a ds41417a-page 76 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 77 pic16f/lf722a/723a 7.0 oscillator module 7.1 overview the oscillator module has a wide variety of clock sources and selection features that allow it to be used in a wide range of applications while maximizing performance and minimizing power consumption. figure 7-1 illustrates a block diagram of the oscillator module. clock sources can be configured from external oscillators, quartz crystal resonators, ceramic resonators and resistor-capacitor (rc) circuits. in addition, the system can be configured to use an internal calibrated high-frequency oscillator as clock source, with a choice of selectable speeds via software. clock source modes are configured by the fosc bits in configuration word 1 (config1). the oscillator module can be configured for one of eight modes of operation. 1. rc ? external resistor-capacitor (rc) with f osc /4 output on osc2/clkout. 2. rcio ? external resistor-capacitor (rc) with i/o on osc2/clkout. 3. intosc ? internal oscillator with f osc /4 output on osc2 and i/o on osc1/clkin. 4. intoscio ? internal oscillator with i/o on osc1/clkin and osc2/clkout. 5. ec ? external clock with i/o on osc2/clkout. 6. hs ? high gain crystal or ceramic resonator mode. 7. xt ? medium gain crystal or ceramic resonator oscillator mode. 8. lp ? low-power crystal mode. figure 7-1: simplified pic ? mcu clock source block diagram (cpu and peripherals) osc1 osc2 sleep external oscillator lp, xt, hs, rc, ec system clock postscaler mux mux 16 mhz/500 khz 8 mhz/250 khz 4 mhz/125 khz 2 mhz/62.5 khz ircf<1:0> 11 10 01 00 fosc<2:0> (configuration word 1) internal oscillator (osccon register) 500 khz intosc 32x mux 0 1 pll pllen (configuration word 1)
pic16f/lf722a/723a ds41417a-page 78 ? 2010 microchip technology inc. 7.2 clock source modes clock source modes can be classified as external or internal. ? internal clock source (intosc) is contained within the oscillator module and derived from a 500 khz high precision oscillator. the oscillator module has eight selectable output frequencies, with a maximum internal frequency of 16 mhz. ? external clock modes rely on external circuitry for the clock source. examples are: oscillator mod- ules (ec mode), quartz crystal resonators or ceramic resonators (lp, xt and hs modes) and resistor-capacitor (rc) mode circuits. the system clock can be selected between external or internal clock sources via the fosc bits of the configuration word 1. 7.3 internal clock modes the oscillator module has eight output frequencies derived from a 500 khz high precision oscillator. the ircf bits of the osccon register select the postscaler applied to the clock source dividing the frequency by 1, 2, 4 or 8. setting the pllen bit of the configuration word 1 locks the internal clock source to 16 mhz before the postscaler is selected by the ircf bits. the pllen bit must be set or cleared at the time of programming; therefore, only the upper or low four clock source frequencies are selectable in software. 7.3.1 intosc and intoscio modes the intosc and intoscio modes configure the internal oscillators as the system clock source when the device is programmed using the oscillator selection or the fosc<2:0> bits in the config1 register. see section 8.0 ?device configuration? for more information. in intosc mode, osc1/clkin is available for general purpose i/o. osc2/clkout outputs the selected internal oscillator frequency divided by 4. the clkout signal may be used to provide a clock for external circuitry, synchronization, calibration, test or other application requirements. in intoscio mode, osc1/clkin and osc2/ clkout are available for general purpose i/o. 7.3.2 frequency select bits (ircf) the output of the 500 khz intosc and 16 mhz intosc, with phase locked loop enabled, connect to a postscaler and multiplexer (see figure 7-1). the internal oscillator frequency select bits (ircf) of the osccon register select the frequency output of the internal oscillator. depending upon the pllen bit, one of four frequencies of two frequency sets can be selected via software: if pllen = 1 , frequency selection is as follows: ?16 mhz ? 8 mhz (default after reset) ?4 mhz ?2 mhz if pllen = 0 , frequency selection is as follows: ?500 khz ? 250 khz (default after reset) ?125 khz ?62.5 khz there is no start-up delay before a new frequency selected in the ircf bits takes effect. this is because the old and new frequencies are derived from intosc via the postscaler and multiplexer. start-up delay specifications are located in table 23-2 in section 23.0 ?electrical specifications? . note: following any reset, the ircf<1:0> bits of the osccon register are set to ? 10 ? and the frequency selection is set to 8 mhz or 250 khz. the user can modify the ircf bits to select a different frequency.
? 2010 microchip technology inc. ds41417a-page 79 pic16f/lf722a/723a 7.4 oscillator control the oscillator control (osccon) register (figure 7-1) displays the status and allows frequency selection of the internal oscillator (intosc) system clock. the osccon register contains the following bits: ? frequency selection bits (ircf) ? status locked bits (icsl) ? status stable bits (icss) register 7-1: osccon: os cillator control register u-0 u-0 r/w-1 r/w-0 r-q r-q u-0 u-0 ? ? ircf1 ircf0 icsl icss ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown q = value depends on condition bit 7-6 unimplemented: read as ? 0 ? bit 5-4 ircf<1:0>: internal oscillator frequency select bits when pllen = 1 (16 mhz intosc) 11 =16mhz 10 = 8 mhz (por value) 01 =4mhz 00 =2mhz when pllen = 0 (500 khz intosc) 11 = 500 khz 10 = 250 khz (por value) 01 = 125 khz 00 = 62.5 khz bit 3 icsl: internal clock oscillator status locked bit (2% stable) 1 = 16 mhz/500 khz internal oscillator (hfiosc) is in lock 0 = 16 mhz/500 khz internal oscillator (hfiosc) has not yet locked bit 2 icss: internal clock oscillator status stable bit (0.5% stable) 1 = 16 mhz/500 khz internal oscillator (hfiosc) has stabilized to its maximum accuracy 0 = 16 mhz/500 khz internal oscillator (hfiosc) has not yet reached its maximum accuracy bit 1-0 unimplemented: read as ? 0 ?
pic16f/lf722a/723a ds41417a-page 80 ? 2010 microchip technology inc. 7.5 oscillator tuning the intosc is factory calibrated but can be adjusted in software by writing to the osctune register (register 7-2). the default value of the osctune register is ? 0 ?. the value is a 6-bit two?s complement number. when the osctune register is modified, the intosc frequency will begin shifting to the new frequency. code execution continues during this shift. there is no indication that the shift has occurred. register 7-2: osctune: osci llator tuning register u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? tun5 tun4 tun3 tun2 tun1 tun0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5-0 tun<5:0>: frequency tuning bits 01 1111 = maximum frequency 01 1110 = ? ? ? 00 0001 = 00 0000 = oscillator module is running at the factory-calibrated frequency. 11 1111 = ? ? ? 10 0000 = minimum frequency
? 2010 microchip technology inc. ds41417a-page 81 pic16f/lf722a/723a 7.6 external clock modes 7.6.1 oscillator start-up timer (ost) if the oscillator module is configured for lp, xt or hs modes, the oscillator start-up timer (ost) counts 1024 oscillations on the osc1 pin before the device is released from reset. this occurs following a power-on reset (por) and when the power-up timer (pwrt) has expired (if configured), or a wake-up from sleep. during this time, the program counter does not increment and program execution is suspended. the ost ensures that the oscillator circuit, using a quartz crystal resonator or ceramic resonator, has started and is providing a stable system clock to the oscillator module. 7.6.2 ec mode the external clock (ec) mode allows an externally generated logic level as the system clock source. when operating in this mode, an external clock source is connected to the osc1 input and the osc2 is available for general purpose i/o. figure 7-2 shows the pin connections for ec mode. the oscillator start-up timer (ost) is disabled when ec mode is selected. therefore, there is no delay in operation after a power-on reset (por) or wake-up from sleep. because the pic ? mcu design is fully static, stopping the external clock input will have the effect of halting the device while leaving all data intact. upon restarting the external clock, the device will resume operation as if no time had elapsed. figure 7-2: exter nal clock (ec) mode operation 7.6.3 lp, xt, hs modes the lp, xt and hs modes support the use of quartz crystal resonators or ceramic resonators connected to osc1 and osc2 (figure 7-3). the mode selects a low, medium or high gain setting of the internal inverter- amplifier to support various resonator types and speed. lp oscillator mode selects the lowest gain setting of the internal inverter-amplifier. lp mode current consumption is the least of the three modes. this mode is best suited to drive resonators with a low drive level specification, for example, tuning fork type crystals. xt oscillator mode selects the intermediate gain setting of the internal inverter-amplifier. xt mode current consumption is the medium of the three modes. this mode is best suited to drive resonators with a medium drive level specification. hs oscillator mode selects the highest gain setting of the internal inverter-amplifier. hs mode current consumption is the highest of the three modes. this mode is best suited for resonators that require a high drive setting. figure 7-3 and figure 7-4 show typical circuits for quartz crystal and ceramic resonators, respectively. figure 7-3: quartz crystal operation (lp, xt or hs mode) osc1/clkin osc2/clkout (1) i/o clock from ext. system pic ? mcu note 1: alternate pin functions are described in section 6.1 ?alternate pin function? . note 1: quartz crystal characteristics vary according to type, package and manufacturer. the user should consult the manufacturer data sheets for specifications and recommended application. 2: always verify oscillator performance over the v dd and temperature range that is expected for the application. 3: for oscillator design assistance, reference the following microchip applications notes: ? an826, ? crystal oscillator basics and crystal selection for rfpic ? and pic ? devices ? (ds00826) ? an849, ? basic pic ? oscillator design ? (ds00849) ? an943, ? practical pic ? oscillator analysis and design ? (ds00943) ? an949, ? making your oscillator work ? (ds00949) note 1: a series resistor (r s ) may be required for quartz crystals with low drive level. 2: the value of r f varies with the oscillator mode selected. c1 c2 quartz r s (1) osc1/clkin r f (2) sleep to internal logic pic ? mcu crystal osc2/clkout
pic16f/lf722a/723a ds41417a-page 82 ? 2010 microchip technology inc. figure 7-4: ceramic resonator operation (xt or hs mode) 7.6.4 external rc modes the external resistor-capacitor (rc) modes support the use of an external rc circuit. this allows the designer maximum flexibility in frequency choice while keeping costs to a minimum when clock accuracy is not required. there are two modes: rc and rcio. in rc mode, the rc circuit connects to osc1. osc2/ clkout outputs the rc oscillator frequency divided by 4. this signal may be used to provide a clock for external circuitry, synchronization, calibration, test or other application requirements. figure 7-5 shows the external rc mode connections. figure 7-5: external rc modes in rcio mode, the rc circuit is connected to osc1. osc2 becomes an additional general purpose i/o pin. the rc oscillator frequency is a function of the supply voltage, the resistor (r ext ) and capacitor (c ext ) values and the operating temperature. other factors affecting the oscillator frequency are: ? threshold voltage variation ? component tolerances ? packaging variations in capacitance the user also needs to take into account variation due to tolerance of external rc components used. table 7-1: summary of registers asso ciated with clock sources note 1: a series resistor (r s ) may be required for ceramic resonators with low drive level. 2: the value of r f varies with the oscillator mode selected. 3: an additional parallel feedback resistor (r p ) may be required for proper ceramic resonator operation. c1 c2 ceramic r s (1) osc1/clkin r f (2) sleep to internal logic pic ? mcu r p (3) resonator osc2/clkout osc2/clkout (1) c ext r ext pic ? mcu osc1/clkin f osc /4 or internal clock v dd v ss recommended values: 10 k ? ? r ext ? 100 k ? , <3v 3 k ? ? r ext ? 100 k ? , 3-5v c ext > 20 pf, 2-5v note 1: alternate pin functions are described in section 6.1 ?alternate pin function? . 2: output depends upon rc or rcio clock mode. i/o (2) name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets (1) config1 (1) ? cp mclre pwrte wdte fosc2 fosc1 fosc0 ? ? osccon ? ? ircf1 ircf0 icsl icss ? ? --10 qq-- --10 qq-- osctune ? ? tun5 tun4 tun3 tun2 tun1 tun0 --00 0000 --uu uuuu legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by oscillators. note 1: see configuration word 1 (register 8-1) for operation of all bits.
? 2010 microchip technology inc. ds41417a-page 83 pic16f/lf722a/723a 8.0 device configuration device configuration consists of configuration word 1 and configuration word 2 registers, code protection and device id. 8.1 configuration words there are several configuration word bits that allow different oscillator and memory protection options. these are implemented as configuration word 1 register at 2007h and configuration word 2 register at 2008h. these registers are only accessible during programming. register 8-1: conf ig1: config uration word register 1 r/p-1 r/p-1 u-1 (4) r/p-1 r/p-1 r/p-1 ? ?debug pllen ? borv boren1 boren0 bit 15 bit 8 u-1 (4) r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 ?cp mclre pwrte wdte fosc2 fosc1 fosc0 bit 7 bit 0 legend: p = programmable bit r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 13 debug : in-circuit debugger mode bit 1 = in-circuit debugger disabled, rb6/icspclk and rb7/icspdat are general purpose i/o pins 0 = in-circuit debugger enabled, rb6/icspclk and rb7/icspdat are dedicated to the debugger bit 12 pllen: intosc pll enable bit 0 = intosc frequency is 500 khz 1 = intosc frequency is 16 mhz (32x) bit 11 unimplemented: read as ? 1 ? bit 10 borv: brown-out reset voltage selection bit 0 = brown-out reset voltage (v bor ) set to 2.5 v nominal 1 = brown-out reset voltage (v bor ) set to 1.9 v nominal bit 9-8 boren<1:0>: brown-out reset selection bits (1) 0x = bor disabled (preconditioned state) 10 = bor enabled during operation and disabled in sleep 11 = bor enabled bit 7 unimplemented: read as ? 1 ? bit 6 cp : code protection bit (2) 1 = program memory code protection is disabled 0 = program memory code protection is enabled bit 5 mclre: re3/mclr pin function select bit (3) 1 = re3/mclr pin function is mclr 0 = re3/mclr pin function is digital input, mclr internally tied to v dd bit 4 pwrte : power-up timer enable bit 1 = pwrt disabled 0 = pwrt enabled bit 3 wdte: watchdog timer enable bit 1 = wdt enabled 0 = wdt disabled note 1: enabling brown-out reset does not automatically enable power-up timer. 2: the entire program memory will be erased when the code protection is turned off. 3: when mclr is asserted in intosc or rc mode, the internal clock oscillator is disabled. 4: mplab ? ide masks unimplemented configuration bits to ? 0 ?.
pic16f/lf722a/723a ds41417a-page 84 ? 2010 microchip technology inc. bit 2-0 fosc<2:0>: oscillator selection bits 111 = rc oscillator: clkout function on ra6/osc2/clkout pin, rc on ra7/osc1/clkin 110 = rcio oscillator: i/o function on ra6/ osc2/clkout pin, rc on ra7/osc1/clkin 101 = intosc oscillator: clkout function on ra6/osc2/clkout pin, i/o function on ra7/osc1/clkin 100 = intoscio oscillator: i/o function on ra6/osc2/clkout pin, i/o function on ra7/osc1/clkin 011 = ec: i/o function on ra6/osc2/clkout pin, clkin on ra7/osc1/clkin 010 = hs oscillator: high-speed crystal/resonator on ra6/osc2/clkout and ra7/osc1/clkin 001 = xt oscillator: crystal/resonator on ra6/osc2/clkout and ra7/osc1/clkin 000 = lp oscillator: low-power crystal on ra6/osc2/clkout and ra7/osc1/clkin register 8-1: config1: configuration word re gister 1 (continued) note 1: enabling brown-out reset does not automatically enable power-up timer. 2: the entire program memory will be erased when the code protection is turned off. 3: when mclr is asserted in intosc or rc mode, the internal clock oscillator is disabled. 4: mplab ? ide masks unimplemented configuration bits to ? 0 ?. register 8-2: conf ig2: config uration word register 2 u-1 (1) u-1 (1) u-1 (1) u-1 (1) u-1 (1) u-1 (1) ? ? ? ? ? ? ? ? bit 15 bit 8 u-1 (1) u-1 (1) r/p-1 r/p-1 u-1 (1) u-1 (1) u-1 (1) u-1 (1) ? ? vcapen1 vcapen0 ? ? ? ? bit 7 bit 0 legend: p = programmable bit r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 13-6 unimplemented : read as ? 1 ? bit 5-4 vcapen<1:0>: voltage regulator capacitor enable bits for the pic16lf722a/723a : these bits are ignored. all v cap pin functions are disabled. for the pic16f722a/723a : 00 =v cap functionality is enabled on ra0 01 =v cap functionality is enabled on ra5 10 =v cap functionality is enabled on ra6 11 = all v cap functions are disabled (not recommended) bit 3-0 unimplemented : read as ? 1 ? note 1: mplab ? ide masks unimplemented configuration bits to ? 0 ?.
? 2010 microchip technology inc. ds41417a-page 85 pic16f/lf722a/723a 8.2 code protection if the code protection bit(s) have not been programmed, the on-chip program memory can be read out using icsp? for verification purposes. 8.3 user id four memory locations (2000h-2003h) are designated as id locations where the user can store checksum or other code identification numbers. these locations are not accessible during normal execution, but are read- able and writable during program/verify mode. only the least significant 7 bits of the id locations are reported when using mplab ide. see the ? pic16f72x/pic16lf72x memory programming specification? (ds41332) for more information. note: the entire flash program memory will be erased when the code protection is turned off. see the ? pic16f72x/pic16lf72x memory programming specification? (ds41332) for more information.
pic16f/lf722a/723a ds41417a-page 86 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 87 pic16f/lf722a/723a 9.0 analog-to-digital converter (adc) module the analog-to-digital converter (adc) allows conversion of an analog input signal to a 8-bit binary representation of that signal. this device uses analog inputs, which are multiplexed into a single sample and hold circuit. the output of the sample and hold is connected to the input of the converter. the converter generates a 8-bit binary result via successive approximation and stores the conversion result into the adc result register (adres). figure 9-1 shows the block diagram of the adc. the adc voltage reference is software selectable to be either internally generated or externally supplied. the adc can generate an interrupt upon completion of a conversion. this interrupt can be used to wake-up the device from sleep. figure 9-1: adc block diagram an0 an1 an2 an4 av dd v ref + adon go/done adref = 10 adref = 0x chs<3:0> v ss an5 an6 an7 an3 an8 an9 an10 reserved fv ref 0000 0001 0010 0011 0100 0101 0111 0110 1000 1001 1010 1011 1100 1101 1110 1111 8 adc adres adref = 11 reserved reserved reserved
pic16f/lf722a/723a ds41417a-page 88 ? 2010 microchip technology inc. 9.1 adc configuration when configuring and using the adc the following functions must be considered: ? port configuration ? channel selection ? adc voltage reference selection ? adc conversion clock source ? interrupt control ? results formatting 9.1.1 port configuration the adc can be used to convert both analog and digital signals. when converting analog signals, the i/o pin should be configured for analog by setting the associated tris and ansel bits. refer to section 6.0 ?i/o ports? for more information. 9.1.2 channel selection the chs bits of the adcon0 register determine which channel is connected to the sample and hold circuit. when changing channels, a delay is required before starting the next conversion. refer to section 9.2 ?adc operation? for more information. 9.1.3 adc v oltage reference the adref bits of the adcon1 register provides control of the positive voltage reference. the positive voltage reference can be either v dd , an external voltage source or the internal fixed voltage reference. the negative voltage reference is always connected to the ground reference. see section 10.0 ?fixed voltage reference? for more details. 9.1.4 conversion clock the source of the conversion clock is software select- able via the adcs bits of the adcon1 register. there are seven possible clock options: ?f osc /2 ?f osc /4 ?f osc /8 ?f osc /16 ?f osc /32 ?f osc /64 ?f rc (dedicated internal oscillator) the time to complete one bit conversion is defined as t ad . one full 8-bit conversion requires 10 t ad periods as shown in figure 9-2. for correct conversion, the appropriate t ad specifica- tion must be met. refer to the a/d conversion require- ments in section 23.0 ?electrical specifications? for more information. table 9-1 gives examples of appro- priate adc clock selections. note: analog voltages on any pin that is defined as a digital input may cause the input buffer to conduct excess current. note: unless using the f rc , any changes in the system clock frequency will change the adc clock frequency, which may adversely affect the adc result.
? 2010 microchip technology inc. ds41417a-page 89 pic16f/lf722a/723a table 9-1: adc clock period (t ad ) v s . device operating frequencies figure 9-2: analog-to-dig ital conversion t ad cycles adc clock period (t ad ) device frequency (f osc ) adc clock source adcs<2:0> 20 mhz 16 mhz 8 mhz 4 mhz 1 mhz fosc/2 000 100 ns (2) 125 ns (2) 250 ns (2) 500 ns (2) 2.0 ? s fosc/4 100 200 ns (2) 250 ns (2) 500 ns (2) 1.0 ? s4.0 ? s fosc/8 001 400 ns (2) 0.5 ? s (2) 1.0 ? s2.0 ? s 8.0 ? s (3) fosc/16 101 800 ns 1.0 ? s2.0 ? s4.0 ? s 16.0 ? s (3) fosc/32 010 1.6 ? s2.0 ? s4.0 ? s 8.0 ? s (3) 32.0 ? s (3) fosc/64 110 3.2 ? s4.0 ? s 8.0 ? s (3) 16.0 ? s (3) 64.0 ? s (3) f rc x11 1.0-6.0 ? s (1,4) 1.0-6.0 ? s (1,4) 1.0-6.0 ? s (1,4) 1.0-6.0 ? s (1,4) 1.0-6.0 ? s (1,4) legend: shaded cells are outside of recommended range. note 1: the f rc source has a typical t ad time of 1.6 ? s for v dd . 2: these values violate the minimum required t ad time. 3: for faster conversion times, the selection of another clock source is recommended. 4: when the device frequency is greater than 1 mhz, the f rc clock source is only recommended if the conversion will be performed during sleep. t ad 1 t ad 2 t ad 3 t ad 4 t ad 5 t ad 6 t ad 7 t ad 8 t ad 9 set go/done bit holding capacitor is disconnected from analog input (typically 100 ns) b7 b6 b5 b4 b3 b2 b1 b0 tcy to t ad conversion starts adres register is loaded, go/done bit is cleared, adif bit is set, holding capacitor is connected to analog input t ad 0
pic16f/lf722a/723a ds41417a-page 90 ? 2010 microchip technology inc. 9.1.5 interrupts the adc module allows for the ability to generate an interrupt upon completion of an analog-to-digital conversion. the adc interrupt flag is the adif bit in the pir1 register. the adc interrupt enable is the adie bit in the pie1 register. the adif bit must be cleared in software. this interrupt can be generated while the device is operating or while in sleep. if the device is in sleep, the interrupt will wake-up the device. upon waking from sleep, the next instruction following the sleep instruc- tion is always executed. if the user is attempting to wake-up from sleep and resume in-line code execu- tion, the gie and peie bits of the intcon register must be disabled. if the gie and peie bits of the intcon register are enabled, execution will switch to the interrupt service routine. please refer to section 9.1.5 ?interrupts? for more information. 9.2 adc operation 9.2.1 starting a conversion to enable the adc module, the adon bit of the adcon0 register must be set to a ? 1 ?. setting the go/ done bit of the adcon0 register to a ? 1 ? will start the analog-to-digital conversion. 9.2.2 completion of a conversion when the conversion is complete, the adc module will: ? clear the go/done bit ? set the adif interrupt flag bit ? update the adres register with new conversion result 9.2.3 terminating a conversion if a conversion must be terminated before completion, the go/done bit can be cleared in software. the adres register will be updated with the partially com- plete analog-to-digital conversion sample. incomplete bits will match the last bit converted. 9.2.4 adc operation during sleep the adc module can operate during sleep. this requires the adc clock source to be set to the f rc option. when the f rc clock source is selected, the adc waits one additional instruction before starting the conversion. this allows the sleep instruction to be executed, which can reduce system noise during the conversion. if the adc interrupt is enabled, the device will wake-up from sleep when the conversion completes. if the adc interrupt is disabled, the adc module is turned off after the conversion completes, although the adon bit remains set. when the adc clock source is something other than f rc , a sleep instruction causes the present conver- sion to be aborted and the adc module is turned off, although the adon bit remains set. 9.2.5 special event trigger the special event trigger of the ccp module allows periodic adc measurements without software inter- vention. when this trigger occurs, the go/done bit is set by hardware and the timer1 counter resets to zero. using the special event trigger does not assure proper adc timing. it is the user?s responsibility to ensure that the adc timing requirements are met. refer to section 15.0 ?capture/compare/pwm (ccp) module? for more information. note 1: the adif bit is set at the completion of every conversion, regardless of whether or not the adc interrupt is enabled. 2: the adc operates during sleep only when the f rc oscillator is selected. note: the go/done bit should not be set in the same instruction that turns on the adc. refer to section 9.2.6 ?a/d conversion procedure? . note: a device reset forces all registers to their reset state. thus, the adc module is turned off and any pending conversion is terminated.
? 2010 microchip technology inc. ds41417a-page 91 pic16f/lf722a/723a 9.2.6 a/d conversion procedure this is an example procedure for using the adc to perform an analog-to-digital conversion: 1. configure port: ? disable pin output driver (refer to the tris register) ? configure pin as analog (refer to the ansel register) 2. configure the adc module: ? select adc conversion clock ? configure voltage reference ? select adc input channel ? turn on adc module 3. configure adc interrupt (optional): ? clear adc interrupt flag ? enable adc interrupt ? enable peripheral interrupt ? enable global interrupt (1) 4. wait the required acquisition time (2) . 5. start conversion by setting the go/done bit. 6. wait for adc conversion to complete by one of the following: ? polling the go/done bit ? waiting for the adc interrupt (interrupts enabled) 7. read adc result. 8. clear the adc interrupt flag (required if interrupt is enabled). example 9-1: a/d conversion note 1: the global interrupt can be disabled if the user is attempting to wake-up from sleep and resume in-line code execution. 2: refer to section 9.3 ?a/d acquisition requirements? . ;this code block configures the adc ;for polling, vdd reference, frc clock ;and an0 input. ; ;conversion start & polling for completion ; are included. ; banksel adcon1 ; movlw b?01110000? ;adc frc clock, ;v dd reference movwf adcon1 ; banksel trisa ; bsf trisa,0 ;set ra0 to input banksel ansela ; bsf ansela,0 ;set ra0 to analog banksel adcon0 ; movlw b?00000001?;an0, on movwf adcon0 ; call sampletime ;acquisiton delay bsf adcon0,go ;start conversion btfsc adcon0,go ;is conversion done? goto $-1 ;no, test again banksel adres ; movf adres,w ;read result movwf result ;store in gpr space
pic16f/lf722a/723a ds41417a-page 92 ? 2010 microchip technology inc. 9.2.7 adc register definitions the following registers are used to control the operation of the adc. register 9-1: adcon0: a/ d control register 0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? chs3 chs2 chs1 chs0 go/done adon bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5-2 chs<3:0>: analog channel select bits 0000 =an0 0001 =an1 0010 =an2 0011 =an3 0100 =an4 0101 =an5 0110 =an6 0111 =an7 1000 =an8 1001 =an9 1010 =an10 1011 =reserved 1100 =reserved 1101 =reserved 1110 =reserved 1111 = fixed voltage reference (fv ref ) bit 1 go/done : a/d conversion status bit 1 = a/d conversion cycle in progress. setting this bit starts an a/d conversion cycle. this bit is automatically cleared by hardware when the a/d conversion has completed. 0 = a/d conversion completed/not in progress bit 0 adon: adc enable bit 1 = adc is enabled 0 = adc is disabled and consumes no operating current
? 2010 microchip technology inc. ds41417a-page 93 pic16f/lf722a/723a register 9-2: adcon1: a/ d control register 1 register 9-3: adres: adc result register u-0 r/w-0 r/w-0 r/w-0 u-0 u-0 r/w-0 r/w-0 ? adcs2 adcs1 adcs0 ? ? adref1 adref0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 unimplemented: read as ? 0 ? bit 6-4 adcs<2:0>: a/d conversion clock select bits 000 =f osc /2 001 =f osc /8 010 =f osc /32 011 =f rc (clock supplied from a dedicated rc oscillator) 100 =f osc /4 101 =f osc /16 110 =f osc /64 111 =f rc (clock supplied from a dedicated rc oscillator) bit 3-2 unimplemented: read as ? 0 ? bit 1-0 adref<1:0>: voltage reference configuration bits 0x =v ref is connected to v dd 10 =v ref is connected to external v ref (ra3/an3) 11 =v ref is connected to internal fixed voltage reference r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x adres7 adres6 adres5 adres4 adres3 adres2 adres1 adres0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 adres<7:0> : adc result register bits 8-bit conversion result.
pic16f/lf722a/723a ds41417a-page 94 ? 2010 microchip technology inc. 9.3 a/d acquisition requirements for the adc to meet its specified accuracy, the charge holding capacitor (c hold ) must be allowed to fully charge to the input channel voltage level. the analog input model is shown in figure 9-3. the source imped- ance (r s ) and the internal sampling switch (r ss ) impedance directly affect the time required to charge the capacitor c hold . the sampling switch (r ss ) impedance varies over the device voltage (v dd ), refer to figure 9-3. the maximum recommended imped- ance for analog sources is 10 k ? . as the source impedance is decreased, the acquisition time may be decreased. after the analog input channel is selected (or changed), an a/d acquisition must be done before the conversion can be started. to calculate the mini- mum acquisition time, equation 9-1 may be used. this equation assumes that 1/2 lsb error is used (256 steps for the adc). the 1/2 lsb error is the maximum error allowed for the adc to meet its specified resolution. equation 9-1: acquisition time example t acq amplifier settling time hold capacitor charging time temperature coefficient ++ = t amp t c t coff ++ = 2s t c temperature - 25c ?? 0.05s/c ?? ?? ++ = t c c hold r ic r ss r s ++ ?? ln(1/511) ? = 10pf 1k ? 7k ? 10k ? ++ ?? ? ln(0.001957) = 1.12 = s t acq 2s 1.12s 50c- 25c ?? 0.05s/c ?? ?? ++ = 4.42s = v applied 1e tc ? rc --------- ? ?? ?? ?? v applied 1 1 2 n1 + ?? 1 ? -------------------------- ? ?? ?? = v applied 1 1 2 n1 + ?? 1 ? -------------------------- ? ?? ?? v chold = v applied 1e t c ? rc --------- - ? ?? ?? ?? v chold = ;[1] v chold charged to within 1/2 lsb ;[2] v chold charge response to v applied ;combining [1] and [2] the value for t c can be approximated with the following equations: solving for t c : therefore: temperature 50c and external impedance of 10k ? 5.0v v dd = assumptions: note: where n = number of bits of the adc. note 1: the reference voltage (v ref ) has no effect on the equation, since it cancels itself out. 2: the charge holding capacitor (c hold ) is not discharged after each conversion. 3: the maximum recommended impedance for analog sources is 10 k ? . this is required to meet the pin leakage specification.
? 2010 microchip technology inc. ds41417a-page 95 pic16f/lf722a/723a figure 9-3: analog input model figure 9-4: adc transfer function c pin va rs anx 5 pf v dd v t ? 0.6v v t ? 0.6v i leakage (1) r ic ? 1k sampling switch ss rss c hold = 10 pf v ss /v ref - 6v sampling switch 5v 4v 3v 2v 567891011 (k ? ) v dd legend: c pin v t i leakage r ic ss c hold = input capacitance = threshold voltage = leakage current at the pin due to = interconnect resistance = sampling switch = sample/hold capacitance various junctions r ss note 1: refer to section 23.0 ?electrical specifications? . r ss = resistance of sampling switch ffh feh adc output code fdh fch 04h 03h 02h 01h 00h full-scale fbh 1 lsb ideal v ss zero-scale transition v ref transition 1 lsb ideal full-scale range analog input voltage
pic16f/lf722a/723a ds41417a-page 96 ? 2010 microchip technology inc. table 9-2: summary of associated adc registers name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets adcon0 ? ? chs3 chs2 chs1 chs0 go/done adon --00 0000 --00 0000 adcon1 ? adcs2 adcs1 adcs0 ? ? adref1 adref0 -000 --00 -000 --00 ansela ? ?ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 --11 1111 --11 1111 anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 --11 1111 --11 1111 adres a/d result register byte xxxx xxxx uuuu uuuu ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 --00 0000 fvrcon fvrrdy fvren ? ? ? ? adfvr1 adfvr0 q0-- --00 q0-- --00 intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 trisb trisb7 trisb6 trisb5 trisb4 tri sb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, ? = unimplemented read as ? 0 ?, q = value depends on condition . shaded cells are not used for adc module.
? 2010 microchip technology inc. ds41417a-page 97 pic16f/lf722a/723a 10.0 fixed voltage reference this device contains an internal voltage regulator. to provide a reference for the regulator, a band gap reference is provided. this band gap is also user accessible via an a/d converter channel. user level band gap functions are controlled by the fvrcon register, which is shown in register 10-1. register 10-1: fvrcon: fixed voltage reference register r-q r/w-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 fvrrdy fvren ? ? ? ? adfvr1 adfvr0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown q = value depends on condition bit 7 fvrrdy: fixed voltage reference ready flag bit 0 = fixed voltage reference output is not active or stable 1 = fixed voltage reference output is ready for use bit 6 fvren (1) : fixed voltage reference enable bit 0 = fixed voltage reference is disabled 1 = fixed voltage reference is enabled bit 5-2 unimplemented: read as ? 0 ? bit 1-0 adfvr<1:0>: a/d converter fixed voltage reference selection bits 00 = a/d converter fixed voltage reference peripheral output is off. 01 = a/d converter fixed voltage reference peripheral output is 1x (1.024v) 10 = a/d converter fixed voltage reference peripheral output is 2x (2.048v) (1) 11 = a/d converter fixed voltage reference peripheral output is 4x (4.096v) (1) note 1: fixed voltage reference output cannot exceed v dd .
pic16f/lf722a/723a ds41417a-page 98 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 99 pic16f/lf722a/723a 11.0 timer0 module the timer0 module is an 8-bit timer/counter with the following features: ? 8-bit timer/counter register (tmr0) ? 8-bit prescaler (shared with watchdog timer) ? programmable internal or external clock source ? programmable external clock edge selection ? interrupt on overflow ? tmr0 can be used to gate timer1 figure 11-1 is a block diagram of the timer0 module. 11.1 timer0 operation the timer0 module can be used as either an 8-bit timer or an 8-bit counter. 11.1.1 8-bit timer mode the timer0 module will increment every instruction cycle, if used without a prescaler. 8-bit timer mode is selected by clearing the t0cs bit of the option register. when tmr0 is written, the increment is inhibited for two instruction cycles immediately following the write. 11.1.2 8-bit counter mode in 8-bit counter mode, the timer0 module will increment on every rising or falling edge of the t0cki pin or the capacitive sensing oscillator (cpsosc) signal. 8-bit counter mode using the t0cki pin is selected by setting the t0cs bit in the option register to ? 1 ? and resetting the t0xcs bit in the cpscon0 register to ? 0 ?. 8-bit counter mode using the capacitive sensing oscillator (cpsosc) signal is selected by setting the t0cs bit in the option register to ? 1 ? and setting the t0xcs bit in the cpscon0 register to ? 1 ?. the rising or falling transition of the incrementing edge for either input source is determined by the t0se bit in the option register. figure 11-1: block diagram of the timer0/wdt prescaler note: the value written to the tmr0 register can be adjusted, in order to account for the two instruction cycle delay when tmr0 is written. t0cki t0se tmr0 wdt time-out ps<2:0> wdte data bus set flag bit t0if on overflow t0cs 0 1 0 1 0 1 8 8 8-bit prescaler 0 1 f osc /4 psa psa psa s ync 2 t cy overflow to timer1 divide by 512 tmr1ge t1gss = 11 1 0 cap. sensing t0xcs oscillator low-power wdt osc
pic16f/lf722a/723a ds41417a-page 100 ? 2010 microchip technology inc. 11.1.3 software programmable prescaler a single software programmable prescaler is available for use with either timer0 or the watchdog timer (wdt), but not both simultaneously. the prescaler assignment is controlled by the psa bit of the option register. to assign the prescaler to timer0, the psa bit must be cleared to a ? 0 ?. there are 8 prescaler options for the timer0 module ranging from 1:2 to 1:256. the pres ca le values are selectable via the ps<2:0> bits of the option register. in order to have a 1:1 prescaler value for the timer0 module, the prescaler must be assigned to the wdt module. the prescaler is not readable or writable. when assigned to the timer0 module, all instructions writing to the tmr0 register will clear the prescaler. 11.1.4 timer0 interrupt timer0 will generate an interrupt when the tmr0 register overflows from ph to 00h. the t0if interrupt flag bit of the intcon register is set every time the tmr0 register overflows, regardless of whether or not the timer0 interrupt is enabled. the t0if bit can only be cleared in software. the timer0 interrupt enable is the t0ie bit of the intcon register. 11.1.5 8-bit counter mode synchronization when in 8-bit counter mode, the incrementing edge on the t0cki pin must be synchronized to the instruction clock. synchronization can be accomplished by sampling the prescaler output on the q2 and q4 cycles of the instruction clock. the high and low periods of the external clocking source must meet the timing requirements as shown in section 23.0 ?electrical specifications? . note: when the prescaler is assigned to wdt, a clrwdt instruction will clear the prescaler along with the wdt. note: the timer0 interrupt cannot wake the processor from sleep since the timer is frozen during sleep.
? 2010 microchip technology inc. ds41417a-page 101 pic16f/lf722a/723a table 11-1: summary of registers associated with timer0 register 11-1: option_reg: option register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 rbpu intedg t0cs t0se psa ps2 ps1 ps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 rbpu : portb pull-up enable bit 1 = portb pull-ups are disabled 0 = portb pull-ups are enabled by individual port latch values bit 6 intedg: interrupt edge select bit 1 = interrupt on rising edge of int pin 0 = interrupt on falling edge of int pin bit 5 t0cs: tmr0 clock source select bit 1 = transition on t0cki pin or cpsosc signal 0 = internal instruction cycle clock (f osc /4) bit 4 t0se: tmr0 source edge select bit 1 = increment on high-to-low transition on t0cki pin 0 = increment on low-to-high transition on t0cki pin bit 3 psa: prescaler assignment bit 1 = prescaler is assigned to the wdt 0 = prescaler is assigned to the timer0 module bit 2-0 ps<2:0>: prescaler rate select bits 000 001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 1 : 1 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 b it v alue tmr0 r ate wdt r ate name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets cpscon0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs 0--- 0000 0--- 0000 intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 tmr0 timer0 module register xxxx xxxx uuuu uuuu trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 legend: ? = un implemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the timer0 module.
pic16f/lf722a/723a ds41417a-page 102 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 103 pic16f/lf722a/723a 12.0 timer1 module with gate control the timer1 module is a 16-bit timer/counter with the following features: ? 16-bit timer/counter register pair (tmr1h:tmr1l) ? programmable internal or external clock source ? 3-bit prescaler ? dedicated lp oscillator circuit ? synchronous or asynchronous operation ? multiple timer1 gate (count enable) sources ? interrupt on overflow ? wake-up on overflow (external clock, asynchronous mode only) ? time base for the capture/compare function ? special event trigger (with ccp) ? selectable gate source polarity ? gate toggle mode ? gate single-pulse mode ? gate value status ? gate event interrupt figure 12-1 is a block diagram of the timer1 module. figure 12-1: timer1 block diagram tmr1h tmr1l t1sync t1ckps<1:0> prescaler 1, 2, 4, 8 0 1 synchronized clock input 2 set flag bit tmr1if on overflow tmr1 (2) tmr1on note 1: st buffer is high speed type when using t1cki. 2: timer1 register increments on rising edge. 3: synchronize does not operate while in sleep. t1g t1osc f osc /4 internal clock t1oso/t1cki t1osi t1oscen 1 0 t1cki tmr1cs<1:0> (1) synchronize (3) det sleep input tmr1ge 0 1 00 01 10 11 from timer0 from timer2 t1gpol d q ck q 0 1 t1gval t1gtm single pulse acq. control t1gspm t1ggo/done t1gss<1:0> en out 10 11 00 01 f osc internal clock cap. sensing from wdt overflow match pr2 overflow r d en q q1 rd t1gcon data bus det interrupt tmr1gif set t1clk f osc /2 internal clock d en q t1g_in tmr1on oscillator
pic16f/lf722a/723a ds41417a-page 104 ? 2010 microchip technology inc. 12.1 timer1 operation the timer1 module is a 16-bit incrementing counter which is accessed through the tmr1h:tmr1l register pair. writes to tmr1h or tmr1l directly update the counter. when used with an internal clock source, the module is a timer and increments on every instruction cycle. when used with an external clock source, the module can be used as either a timer or counter and incre- ments on every selected edge of the external source. timer1 is enabled by configuring the tmr1on and tmr1ge bits in the t1con and t1gcon registers, respectively. table 12-1 displays the timer1 enable selections. 12.2 clock source selection the tmr1cs<1:0> and t1oscen bits of the t1con register are used to select the clock source for timer1. table 12-2 displays the clock source selections. 12.2.1 internal clock source when the internal clock source is selected the tmr1h:tmr1l register pair will increment on multiples of f isc as determined by the timer1 prescaler. 12.2.2 external clock source when the external clock source is selected, the timer1 module may work as a timer or a counter. when enabled to count, timer1 is increment ed on the rising edge of the external clock input t1cki or the capacitive sensing oscillator signal. either of these external clock sources can be synchronized to the microcontroller system clock or they can run asynchronously. when used as a timer with a clock oscillator, an external 32.768 khz crystal can be used in conjunction with the dedicated internal oscillator circuit. table 12-1: timer1 enable selections tmr1on tmr1ge timer1 operation 00 off 01 off 10 always on 11 count enabled note: in counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge after any one or more of the following conditions: ?timer1 enabled after por ?write to tmr1h or tmr1l ?timer1 is disabled ?timer1 is disabled (tmr1on = 0 ) when t1cki is high then timer1 is enabled (tmr1on= 1 ) when t1cki is low. table 12-2: clock source selections tmr1cs1 tmr1cs0 t1oscen clock source 01x system clock (f osc ) 00x instruction clock (f osc /4) 11x capacitive sensing oscillator 100 external clocking on t1cki pin 101 oscillator circuit on t1osi/t1oso pins
? 2010 microchip technology inc. ds41417a-page 105 pic16f/lf722a/723a 12.3 timer1 prescaler timer1 has four prescaler options allowing 1, 2, 4 or 8 divisions of the clock input. the t1ckps bits of the t1con register control the prescale counter. the prescale counter is not directly readable or writable; however, the prescaler counter is cleared upon a write to tmr1h or tmr1l. 12.4 timer1 oscillator a dedicated low-power 32.768 khz oscillator circuit is built-in between pins t1osi (input) and t1oso (amplifier output). this internal circuit is to be used in conjunction with an external 32.768 khz crystal. the oscillator circuit is enabled by setting the t1oscen bit of the t1con register. the oscillator will continue to run during sleep. 12.5 timer1 operation in asynchronous counter mode if control bit t1sync of the t1con register is set, the external clock input is not synchronized. the timer increments asynchronously to the internal phase clocks. if external clock source is selected then the timer will continue to run during sleep and can generate an interrupt on overflow, which will wake-up the processor. however, special precautions in software are needed to read/write the timer (see section 12.5.1 ?reading and writing timer1 in asynchronous counter mode? ). 12.5.1 reading and writing timer1 in asynchronous counter mode reading tmr1h or tmr1l while the timer is running from an external asynchronous clock will ensure a valid read (taken care of in hardware). however, the user should keep in mind that reading the 16-bit timer in two 8-bit values itself, poses certain problems, since the timer may overflow between the reads. for writes, it is recommended that the user simply stop the timer and write the desired values. a write contention may occur by writing to the timer registers, while the register is incrementing. this may produce an unpredictable value in the tmr1h:tmr1l register pair. note: the oscillator requires a start-up and stabilization time before use. thus, t1oscen should be set and a suitable delay observed prior to enabling timer1. note: when switching from synchronous to asynchronous operation, it is possible to skip an increment. when switching from asynchronous to synchronous operation, it is possible to produce an additional increment.
pic16f/lf722a/723a ds41417a-page 106 ? 2010 microchip technology inc. 12.6 timer1 gate timer1 can be configured to count freely or the count can be enabled and disabled using timer1 gate circuitry. this is also referred to as timer1 gate count enable. timer1 gate can also be driven by multiple selectable sources. 12.6.1 timer1 gate count enable the timer1 gate is enabled by setting the tmr1ge bit of the t1gcon register. the polarity of the timer1 gate is configured using the t1gpol bit of the t1gcon register. when timer1 gate (t1g) input is active, timer1 will increment on the rising edge of the timer1 clock source. when timer1 gate input is inactive, no incrementing will occur and timer1 will hold the current count. see figure 12-3 for timing details. 12.6.2 timer1 gate source selection the timer1 gate source can be selected from one of four different sources. source selection is controlled by the t1gss bits of the t1gcon register. the polarity for each available source is also selectable. polarity selection is controlled by the t1gpol bit of the t1gcon register. table 12-4: timer1 gate sources 12.6.2.1 t1g pin gate operation the t1g pin is one source for timer1 gate control. it can be used to supply an external source to the timer1 gate circuitry. 12.6.2.2 timer0 overflow gate operation when timer0 increments from ffh to 00h, a low-to- high pulse will automatically be generated and inter- nally supplied to the timer1 gate circuitry. 12.6.2.3 timer2 match gate operation the tmr2 register will increment until it matches the value in the pr2 register. on the very next increment cycle, tmr2 will be reset to 00h. when this reset occurs, a low-to-high pulse will automatically be generated and internally supplied to the timer1 gate circuitry. 12.6.2.4 watchdog overflow gate operation the watchdog timer oscillator, prescaler and counter will be automatically turned on when tmr1ge = 1 and t1gss selects the wdt as a gate source for timer1 (t1gss = 11 ). tmr1on does not factor into the oscil- lator, prescaler and counter enable. see table 12-5. the psa and ps bits of the option register still control what time-out interval is selected. changing the prescaler during operation may result in a spurious capture. enabling the watchdog timer oscillator does not automatically enable a watchdog reset or wake-up from sleep upon counter overflow. as the gate signal coming from the wdt counter will generate different pulse widths depending on if the wdt is enabled, when the clrwdt instruction is executed, and so on, toggle mode must be used. a specific sequence is required to put the device into the correct state to capture the next wdt counter interval. table 12-3: timer1 gate enable selections t1clk t1gpol t1g timer1 operation ? 00 counts ? 01 holds count ? 10 holds count ? 11 counts t1gss timer1 gate source 00 timer1 gate pin 01 overflow of timer0 (tmr0 increments from ffh to 00h) 10 timer2 match pr2 (tmr2 increments to match pr2) 11 count enabled by wdt overflow (watchdog time-out interval expired) note: when using the wdt as a gate source for timer1, operations that clear the watchdog timer ( clrwdt , sleep instructions) will affect the time interval being measured for capacitive sensing. this includes waking from sleep. all other interrupts that might wake the device from sleep should be disabled to prevent them from disturbing the measurement period.
? 2010 microchip technology inc. ds41417a-page 107 pic16f/lf722a/723a table 12-5: wdt/timer1 gate interaction 12.6.3 timer1 gate toggle mode when timer1 gate toggle mode is enabled, it is pos- sible to measure the full-cycle length of a timer1 gate signal, as opposed to the duration of a single level pulse. the timer1 gate source is routed through a flip-flop that changes state on every incrementing edge of the sig- nal. see figure 12-4 for timing details. timer1 gate toggle mode is enabled by setting the t1gtm bit of the t1gcon register. when the t1gtm bit is cleared, the flip-flop is cleared and held clear. this is necessary in order to control which edge is measured. 12.6.4 timer1 gate single-pulse mode when timer1 gate single-pulse mode is enabled, it is possible to capture a single pulse gate event. timer1 gate single-pulse mode is first enabled by setting the t1gspm bit in the t1gcon register. next, the t1ggo/done bit in the t1gcon register must be set. the timer1 will be fully enabled on the next incrementing edge. on the next trailing edge of the pulse, the t1ggo/done bit will automatically be cleared. no other gate events will be allowed to increment timer1 until the t1ggo/done bit is once again set in software. clearing the t1gspm bit of the t1gcon register will also clear the t1ggo/done bit. see figure 12-5 for timing details. enabling the toggle mode and the single-pulse mode simultaneously will permit both sections to work together. this allows the cycle times on the timer1 gate source to be measured. see figure 12-6 for timing details. 12.6.5 timer1 gate value status when timer1 gate value status is utilized, it is possible to read the most current level of the gate control value. the value is stored in the t1gval bit in the t1gcon register. the t1gval bit is valid even when the timer1 gate is not enabled (tmr1ge bit is cleared). 12.6.6 timer1 gate event interrupt when timer1 gate event interrupt is enabled, it is pos- sible to generate an interrupt upon the completion of a gate event. when the falling edge of t1gval occurs, the tmr1gif flag bit in the pir1 register will be set. if the tmr1gie bit in the pie1 register is set, then an interrupt will be recognized. the tmr1gif flag bit operates even when the timer1 gate is not enabled (tmr1ge bit is cleared). wdte tmr1ge = 1 and t1gss = 11 wdt oscillator enable wdt reset wake-up wdt available for t1g source 1 n yyy n 1 y yyy y 0 y ynn y 0 n nnn n note: enabling toggle mode at the same time as changing the gate polarity may result in indeterminate operation.
pic16f/lf722a/723a ds41417a-page 108 ? 2010 microchip technology inc. 12.7 timer1 interrupt the timer1 register pair (tmr1h:tmr1l) increments to ffffh and rolls over to 0000h. when timer1 rolls over, the timer1 interrupt flag bit of the pir1 register is set. to enable the interrupt on rollover, you must set these bits: ? tmr1on bit of the t1con register ? tmr1ie bit of the pie1 register ? peie bit of the intcon register ? gie bit of the intcon register the interrupt is cleared by clearing the tmr1if bit in the interrupt service routine. 12.8 timer1 operation during sleep timer1 can only operate during sleep when setup in asynchronous counter mode. in this mode, an external crystal or clock source can be used to increment the counter. to set up the timer to wake the device: ? tmr1on bit of the t1con register must be set ? tmr1ie bit of the pie1 register must be set ? peie bit of the intcon register must be set ? t1sync bit of the t1con register must be set ? tmr1cs bits of the t1con register must be configured ? t1oscen bit of the t1con register must be configured ? tmr1gie bit of the t1gcon register must be configured the device will wake-up on an overflow and execute the next instructions. if the gie bit of the intcon register is set, the device will call the interrupt service routine (0004h). 12.9 ccp capture/compare time base the ccp module uses the tmr1h:tmr1l register pair as the time base when operating in capture or compare mode. in capture mode, the value in the tmr1h:tmr1l register pair is copied into the ccpr1h:ccpr1l register pair on a configured event. in compare mode, an event is triggered when the value ccpr1h:ccpr1l register pair matches the value in the tmr1h:tmr1l register pair. this event can be a special event trigger. for more information, see section 15.0 ?capture/ compare/pwm (ccp) module? . 12.10 ccp special event trigger when the ccp is configured to trigger a special event, the trigger will clear the tmr1h:tmr1l register pair. this special event does not cause a timer1 interrupt. the ccp module may still be configured to generate a ccp interrupt. in this mode of operation, the ccpr1h:ccpr1l register pair becomes the period register for timer1. timer1 should be synchronized to the f osc /4 to utilize the special event trigger. asynchronous operation of timer1 can cause a special event trigger to be missed. in the event that a write to tmr1h or tmr1l coincides with a special event trigger from the ccp, the write will take precedence. for more information, see section 9.2.5 ?special event trigger? . figure 12-2: timer1 incrementing edge note: the tmr1h:tmr1l register pair and the tmr1if bit should be cleared before enabling interrupts. t1cki = 1 when tmr1 enabled t1cki = 0 when tmr1 enabled note 1: arrows indicate counter increments. 2: in counter mode, a falling edge must be registered by the count er prior to the first incrementing rising edge of the clock.
? 2010 microchip technology inc. ds41417a-page 109 pic16f/lf722a/723a figure 12-3: timer1 gate count enable mode figure 12-4: timer1 gate toggle mode tmr1ge t1gpol t1g_in t1cki t1gval timer1 n n + 1 n + 2 n + 3 n + 4 tmr1ge t1gpol t1gtm t1g_in t1cki t1gval timer1 n n + 1 n + 2 n + 3 n + 4 n + 5 n + 6 n + 7 n + 8
pic16f/lf722a/723a ds41417a-page 110 ? 2010 microchip technology inc. figure 12-5: timer1 gate single-pulse mode tmr1ge t1gpol t1g_in t1cki t1gval timer1 n n + 1 n + 2 t1gspm t1ggo/ done set by software cleared by hardware on falling edge of t1gval set by hardware on falling edge of t1gval cleared by software cleared by software tmr1gif counting enabled on rising edge of t1g
? 2010 microchip technology inc. ds41417a-page 111 pic16f/lf722a/723a figure 12-6: timer1 gate single-pulse and toggle combined mode tmr1ge t1gpol t1g_in t1cki t1gval timer1 nn + 1 n + 2 t1gspm t1ggo/ done set by software cleared by hardware on falling edge of t1gval set by hardware on falling edge of t1gval cleared by software cleared by software tmr1gif t1gtm counting enabled on rising edge of t1g n + 4 n + 3
pic16f/lf722a/723a ds41417a-page 112 ? 2010 microchip technology inc. 12.11 timer1 control register the timer1 control register (t1con), shown in register 12-1, is used to control timer1 and select the various features of the timer1 module. register 12-1: t1con: ti mer1 control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 tmr1cs<1:0>: timer1 clock source select bits 11 = timer1 clock source is capacitive sensing oscillator (caposc) 10 = timer1 clock source is pin or oscillator: if t1oscen = 0 : external clock from t1cki pin (on the rising edge) if t1oscen = 1 : crystal oscillator on t1osi/t1oso pins 01 = timer1 clock source is system clock (f osc ) 00 = timer1 clock source is instruction clock (f osc /4) bit 5-4 t1ckps<1:0>: timer1 input clock prescale select bits 11 = 1:8 prescale value 10 = 1:4 prescale value 01 = 1:2 prescale value 00 = 1:1 prescale value bit 3 t1oscen: lp oscillator enable control bit 1 = dedicated timer1 oscillator circuit enabled 0 = dedicated timer1 oscillator circuit disabled bit 2 t 1sync : timer1 external clock input synchronization control bit tmr1cs<1:0> = 1x 1 = do not synchronize external clock input 0 = synchronize external clock input with system clock (f osc ) tmr1cs<1:0> = 0x this bit is ignored. timer1 uses the internal clock when tmr1cs<1:0> = 1x . bit 1 unimplemented: read as ? 0 ? bit 0 tmr1on: timer1 on bit 1 = enables timer1 0 = stops timer1 clears timer1 gate flip-flop
? 2010 microchip technology inc. ds41417a-page 113 pic16f/lf722a/723a 12.12 timer1 gate control register the timer1 gate control register (t1gcon), shown in register 12-2, is used to control timer1 gate. register 12-2: t1gcon: timer1 gate control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r-x r/w-0 r/w-0 tmr1ge t1gpol t1gtm t1gspm t1ggo/ done t1gval t1gss1 t1gss0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 tmr1ge: timer1 gate enable bit if tmr1on = 0 : this bit is ignored if tmr1on = 1 : 1 = timer1 counting is controlled by the timer1 gate function 0 = timer1 counts regardless of timer1 gate function bit 6 t1gpol: timer1 gate polarity bit 1 = timer1 gate is active-high (timer1 counts when gate is high) 0 = timer1 gate is active-low (timer1 counts when gate is low) bit 5 t1gtm: timer1 gate toggle mode bit 1 = timer1 gate toggle mode is enabled. 0 = timer1 gate toggle mode is disabled and toggle flip flop is cleared timer1 gate flip-flop toggles on every rising edge. bit 4 t1gspm: timer1 gate single pulse mode bit 1 = timer1 gate single-pulse mode is enabled and is controlling timer1 gate 0 = timer1 gate single-pulse mode is disabled bit 3 t1ggo/done : timer1 gate single-pulse acquisition status bit 1 = timer1 gate single-pulse acquisition is ready, waiting for an edge 0 = timer1 gate single-pulse acquisition has completed or has not been started this bit is automatically cleared when t1gspm is cleared. bit 2 t1gval: timer1 gate current state bit indicates the current state of the timer1 gate that could be provided to tmr1h:tmr1l. unaffected by timer1 gate enable (tmr1ge). bit 1-0 t1gss<1:0>: timer1 gate source select bits 00 = timer1 gate pin 01 = timer0 overflow output 10 = tmr2 match pr2 output 11 = watchdog timer scaler overflow watchdog timer oscillator is turned on if tmr1ge = 1 , regardless of the state of tmr1on
pic16f/lf722a/723a ds41417a-page 114 ? 2010 microchip technology inc. table 12-6: summary of registers associated with timer1 name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets anselb ? ?ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 --11 1111 --11 1111 ccp1con ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 --00 0000 ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 --00 0000 intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx xxxx xxxx xxxx tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 0000 00-0 uuuu uu-u t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/ done t1gval t1gss1 t1gss0 0000 0x00 uuuu uxuu legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used by the timer1 module.
? 2010 microchip technology inc. ds41417a-page 115 pic16f/lf722a/723a 13.0 timer2 module the timer2 module is an 8-bit timer with the following features: ? 8-bit timer register (tmr2) ? 8-bit period register (pr2) ? interrupt on tmr2 match with pr2 ? software programmable prescaler (1:1, 1:4, 1:16) ? software programmable postscaler (1:1 to 1:16) see figure 13-1 for a block diagram of timer2. 13.1 timer2 operation the clock input to the timer2 module is the system instruction clock (f osc /4). the clock is fed into the timer2 prescaler, which has prescale options of 1:1, 1:4 or 1:16. the output of the prescaler is then used to increment the tmr2 register. the values of tmr2 and pr2 are constantly compared to determine when they match. tmr2 will increment from 00h until it matches the value in pr2. when a match occurs, two things happen: ? tmr2 is reset to 00h on the next increment cycle. ? the timer2 postscaler is incremented. the match output of the timer2/pr2 comparator is then fed into the timer2 postscaler. the postscaler has postscale options of 1:1 to 1:16 inclusive. the output of the timer2 postscaler is used to set the tmr2if interrupt flag bit in the pir1 register. the tmr2 and pr2 registers are both fully readable and writable. on any reset, the tmr2 register is set to 00h and the pr2 register is set to ffh. timer2 is turned on by setting the tmr2on bit in the t2con register to a ? 1 ?. timer2 is turned off by clearing the tmr2on bit to a ? 0 ?. the timer2 prescaler is controlled by the t2ckps bits in the t2con register. the timer2 postscaler is controlled by the toutps bits in the t2con register. the prescaler and postscaler counters are cleared when: ? a write to tmr2 occurs. ? a write to t2con occurs. ? any device reset occurs (power-on reset, mclr reset, watchdog timer reset, or brown-out reset). figure 13-1: timer2 block diagram note: tmr2 is not cleared when t2con is written. comparator tmr2 sets flag tmr2 output reset postscaler prescaler pr2 2 f osc /4 1:1 to 1:16 1:1, 1:4, 1:16 eq 4 bit tmr2if toutps<3:0> t2ckps<1:0>
pic16f/lf722a/723a ds41417a-page 116 ? 2010 microchip technology inc. table 13-1: summary of registers associated with timer2 register 13-1: t2con: ti mer2 control register u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 unimplemented: read as ? 0 ? bit 6-3 toutps<3:0>: timer2 output postscaler select bits 0000 = 1:1 postscaler 0001 = 1:2 postscaler 0010 = 1:3 postscaler 0011 = 1:4 postscaler 0100 = 1:5 postscaler 0101 = 1:6 postscaler 0110 = 1:7 postscaler 0111 = 1:8 postscaler 1000 = 1:9 postscaler 1001 = 1:10 postscaler 1010 = 1:11 postscaler 1011 = 1:12 postscaler 1100 = 1:13 postscaler 1101 = 1:14 postscaler 1110 = 1:15 postscaler 1111 = 1:16 postscaler bit 2 tmr2on: timer2 on bit 1 = timer2 is on 0 = timer2 is off bit 1-0 t2ckps<1:0>: timer2 clock prescale select bits 00 = prescaler is 1 01 = prescaler is 4 1x = prescaler is 16 name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pr2 timer2 module period register 1111 1111 1111 1111 tmr2 holding register for the 8-bit tmr2 register 0000 0000 0000 0000 t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 legend: x = unknown, u = unchanged, - = unimplemented read as ? 0 ?. shaded cells are not used for timer2 module.
? 2010 microchip technology inc. ds41417a-page 117 pic16f/lf722a/723a 14.0 capacitive sensing module the capacitive sensing module allows for an interaction with an end user without a mechanical interface. in a typical application, the capacitive sensing module is attached to a pad on a printed circuit board (pcb), which is electrically isolated from the end user. when the end user places their finger over the pcb pad, a capacitive load is added, causing a frequency shift in the capacitive sensing module. the capacitive sensing module requires software and at least one timer resource to determine the change in frequency. key features of this module include: ? analog mux for monitoring multiple inputs ? capacitive sensing oscillator ? multiple timer resources ? software control ? operation during sleep figure 14-1: capacitive sensing block diagram t0cs cps0 cps1 cps2 cps3 cps4 cps5 cps6 cps7 cpsch<2:0> capacitive sensing oscillator cpsosc cpson cpsrng<1:0> tmr0 0 1 set t0if overflow t0xcs 0 1 t0cki t1cs<1:0> t1osc/ t1cki tmr1h:tmr1l en t1gsel<1:0> timer1 gate control logic t1g cpsout tmr2 timer2 module set tmr2if overflow postscaler cpsclk note 1: if cpson = 0 , disabling capacitive sensing, no channel is selected. f osc /4 f osc f osc /4 timer0 module timer1 module cpson (1) wdt wdt event overflow watchdog timer module scaler ps<2:0> lp wdt osc
pic16f/lf722a/723a ds41417a-page 118 ? 2010 microchip technology inc. 14.1 analog mux the capacitive sensing module can monitor up to 16 inputs. the capacitive sensing inputs are defined as cps<15:0>. to determine if a frequency change has occurred the user must: ? select the appropriate cps pin by setting the cpsch<3:0> bits of the cpscon1 register ? set the corresponding ansel bit ? set the corresponding tris bit ? run the software algorithm selection of the cpsx pin while the module is enabled will cause the capacitive sensing oscillator to be on the cpsx pin. failure to set the corresponding ansel and tris bits can cause the capacitive sensing oscillator to stop, leading to false frequency readings. 14.2 capacitive sensing oscillator the capacitive sensing oscillator consists of a constant current source and a constant current sink, to produce a triangle waveform. the cpsout bit of the cpscon0 register shows the status of the capacitive sensing oscillator, whether it is a sinking or sourcing current. the oscillator is designed to drive a capacitive load (single pcb pad) and at the same time, be a clock source to either timer0 or timer1. the oscillator has three different current settings as defined by cpsrng<1:0> of the cpscon0 register. the different current settings for the oscillator serve two purposes: ? maximize the number of counts in a timer for a fixed time base ? maximize the count differential in the timer during a change in frequency 14.3 timer resources to measure the change in frequency of the capacitive sensing oscillator, a fixed time base is required. for the period of the fixed time base, the capacitive sensing oscillator is used to clock either timer0 or timer1. the frequency of the capacitive sensing oscillator is equal to the number of counts in the timer divided by the period of the fixed time base. 14.4 fixed time base to measure the frequency of the capacitive sensing oscillator, a fixed time base is required. any timer resource or software loop can be used to establish the fixed time base. it is up to the end user to determine the method in which the fixed time base is generated. 14.4.1 timer0 to select timer0 as the timer resource for the capacitive sensing module: ? set the t0xcs bit of the cpscon0 register ? clear the t0cs bit of the option register when timer0 is chosen as the timer resource, the capacitive sensing oscillator will be the clock source for timer0. refer to section 11.0 ?timer0 module? for additional information. 14.4.2 timer1 to select timer1 as the timer resource for the capacitive sensing module, set the tmr1cs<1:0> of the t1con register to ? 11 ?. when timer1 is chosen as the timer resource, the capacitive sensing oscillator will be the clock source for timer1. because the timer1 module has a gate control, developing a time base for the frequency measurement can be simplified using either: ? the timer0 overflow flag ? the timer2 overflow flag ? the wdt overflow flag it is recommended that one of these flags, in conjunc- tion with the toggle mode of the timer1 gate, is used to develop the fixed time base required by the software portion of the capacitive sensing module. refer to section 12.0 ?timer1 module with gate control? for additional information. table 14-1: timer1 enable function note: the fixed time base can not be generated by the timer resource the capacitive sensing oscillator is clocking. tmr1on tmr1ge timer1 operation 00 off 01 off 10 on 11 count enabled by input
? 2010 microchip technology inc. ds41417a-page 119 pic16f/lf722a/723a 14.5 software control the software portion of the capacitive sensing module is required to determine the change in frequency of the capacitive sensing oscillator. this is accomplished by the following: ? setting a fixed time base to acquire counts on timer0 or timer1 ? establishing the nominal frequency for the capacitive sensing oscillator ? establishing the reduced frequency for the capacitive sensing oscillator due to an additional capacitive load ? set the frequency threshold 14.5.1 nominal frequency (no capacitive load) to determine the nominal frequency of the capacitive sensing oscillator: ? remove any extra capacitive load on the selected cpsx pin ? at the start of the fixed time base, clear the timer resource ? at the end of the fixed time base save the value in the timer resource the value of the timer resource is the number of oscillations of the capacitive sensing oscillator for the given time base. the frequency of the capacitive sensing oscillator is equal to the number of counts on in the timer divided by the period of the fixed time base. 14.5.2 reduced frequency (additional capacitive load) the extra capacitive load will cause the frequency of the capacitive sensing oscillator to decrease. to determine the reduced frequency of the capacitive sensing oscillator: ? add a typical capacitive load on the selected cpsx pin ? use the same fixed time base as the nominal frequency measurement ? at the start of the fixed time base, clear the timer resource ? at the end of the fixed time base save the value in the timer resource the value of the timer resource is the number of oscil- lations of the capacitive sensing oscillator with an addi- tional capacitive load. the frequency of the capacitive sensing oscillator is equal to the number of counts on in the timer divided by the period of the fixed time base. this frequency should be less than the value obtained during the nominal frequency measurement. 14.5.3 frequency threshold the frequency threshold should be placed midway between the value of nominal frequency and the reduced frequency of the capacitive sensing oscillator. refer to application note an1103, ? software handling for capacitive sensing ? (ds01103) for more detailed information the software required for capacitive sensing module. note: for more information on general capacitive sensing refer to application notes: ?an1101, ? introduction to capacitive sensing ? (ds01101) ?an1102, ? layout and physical design guidelines for capacitive sensing ? (ds01102)
pic16f/lf722a/723a ds41417a-page 120 ? 2010 microchip technology inc. 14.6 operation during sleep the capacitive sensing oscillator will continue to run as long as the module is enabled, independent of the part being in sleep. in order for the software to determine if a frequency change has occurred, the part must be awake. however, the part does not have to be awake when the timer resource is acquiring counts. one way to acquire the timer1 counts while in sleep is to have timer1 gated with the overflow of the watchdog timer. this can be accomplished using the following steps: 1. configure the watchdog time-out overflow as the timer1?s gate source t1gss<1:0> = 11 . 2. set timer1 gate to toggle mode by setting the t1gtm bit of the t1gcon register. 3. set the tmr1ge bit of the t1gcon register. 4. set tmr1on bit of the t1con register. 5. enable capacitive sensing module with the appropriate current settings and pin selection. 6. clear timer1. 7. put the part to sleep. 8. on the first wdt overflow, the capacitive sens- ing oscillator will begin to increment timer1. then put the part to sleep. 9. on the second wdt overflow timer1 will stop incrementing. then run the software routine to determine if a frequency change has occurred. refer to section 12.0 ?timer1 module with gate control? for additional information. note 1: when using the wdt to set the interval on timer1, any other source that wakes the part up early will cause the wdt over- flow to be delayed, affecting the value captured by timer1. 2: timer0 does not operate when in sleep, and therefore cannot be used for capacitive sense measurements in sleep.
? 2010 microchip technology inc. ds41417a-page 121 pic16f/lf722a/723a register 14-1: cpscon0: capaciti ve sensing control register 0 r/w-0 u-0 u-0 u-0 r/w-0 r/w-0 r-0 r/w-0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 cpson: capacitive sensing module enable bit 1 = capacitive sensing module is operating 0 = capacitive sensing module is shut off and consumes no operating current bit 6-4 unimplemented: read as ? 0 ? bit 3-2 cpsrng<1:0>: capacitive sensing oscillator range bits 00 = oscillator is off. 01 = oscillator is in low range. charge/discharge current is nominally 0.1 a. 10 = oscillator is in medium range. charge/discharge current is nominally 1.2 a. 11 = oscillator is in high range. charge/discharge current is nominally 18 a. bit 1 cpsout: capacitive sensing oscillator status bit 1 = oscillator is sourcing current (current flowing out the pin) 0 = oscillator is sinking current (current flowing into the pin) bit 0 t0xcs: timer0 external clock source select bit if t0cs = 1 the t0xcs bit controls which clock external to the core/timer0 module supplies timer0: 1 = timer0 clock source is the capacitive sensing oscillator 0 = timer0 clock source is the t0cki pin if t0cs = 0 timer0 clock source is controlled by the core/timer0 module and is f osc /4.
pic16f/lf722a/723a ds41417a-page 122 ? 2010 microchip technology inc. table 14-2: summary of registers as sociated with capacitive sensing register 14-2: cpscon1: capaciti ve sensing control register 1 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 ? ? ? ? ? cpsch2 cpsch1 cpsch0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-3 unimplemented: read as ? 0 ? bit 2-0 cpsch<2:0> : capacitive sensing channel select bits if cpson = 0 : these bits are ignored. no channel is selected. if cpson = 1 : 0000 = channel 0, (cps0) 0001 = channel 1, (cps1) 0010 = channel 2, (cps2) 0011 = channel 3, (cps3) 0100 = channel 4, (cps4) 0101 = channel 5, (cps5) 0110 = channel 6, (cps6) 0111 = channel 7, (cps7) name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets ansela ? ? ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 --11 1111 --11 1111 anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 --11 1111 --11 1111 option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 0000 00-0 0000 00-0 t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 legend: - = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the capacitive sensing module.
? 2010 microchip technology inc. ds41417a-page 123 pic16f/lf722a/723a 15.0 capture/compare/pwm (ccp) module the capture/compare/pwm module is a peripheral which allows the user to time and control different events. in capture mode, the peripheral allows the timing of the duration of an event. the compare mode allows the user to trigger an external event when a predetermined amount of time has expired. the pwm mode can generate a pulse-width modulated signal of varying frequency and duty cycle. the timer resources used by the module are shown in table 15-1. additional information on ccp modules is available in the application note an594, ?using the ccp modules? (ds00594). table 15-1: ccp mode ? timer resources required table 15-2: interaction of two ccp modules ccp mode timer resource capture timer1 compare timer1 pwm timer2 ccp1 mode ccp2 mode interaction capture capture same tmr1 time base capture compare same tmr1 time base (1, 2) compare compare same tmr1 time base (1, 2) pwm pwm the pwms will have the same frequency and update rate (tmr2 interrupt). the rising edges will be aligned. pwm capture none pwm compare none note 1: if ccp2 is configured as a special event trigger, ccp1 will clear timer1, affecting the value captured on the ccp2 pin. 2: if ccp1 is in capture mode and ccp2 is configured as a special event trigger, ccp2 will clear timer1, affecting the value captured on the ccp1 pin. note: ccprx and ccpx throughout this document refer to ccpr1 or ccpr2 and ccp1 or ccp2, respectively.
pic16f/lf722a/723a ds41417a-page 124 ? 2010 microchip technology inc. register 15-1: ccpxcon: ccpx control register u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? dcxb1 dcxb0 ccpxm3 ccpxm2 ccpxm1 ccpxm0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5-4 dcxb<1:0> : pwm duty cycle least significant bits capture mode : unused compare mode: unused pwm mode: these bits are the two lsbs of the pwm duty cycle. the eight msbs are found in ccprxl. bit 3-0 ccpxm<3:0>: ccp mode select bits 0000 = capture/compare/pwm off (resets ccp module) 0001 = unused (reserved) 0010 = compare mode, toggle output on match (ccpxif bit of the pirx register is set) 0011 = unused (reserved) 0100 = capture mode, every falling edge 0101 = capture mode, every rising edge 0110 = capture mode, every 4th rising edge 0111 = capture mode, every 16th rising edge 1000 = compare mode, set output on match (ccpxif bit of the pirx register is set) 1001 = compare mode, clear output on match (ccpxif bit of the pirx register is set) 1010 = compare mode, generate software interrupt on match (ccpxif bit is set of the pirx register, ccpx pin is unaffected) 1011 = compare mode, trigger special event (ccpxif bit of the pirx register is set, tmr1 is reset and a/d conversion (1) is started if the adc module is enabled. ccpx pin is unaffected.) 11xx = pwm mode. note 1: a/d conversion start feature is available only on ccp2.
? 2010 microchip technology inc. ds41417a-page 125 pic16f/lf722a/723a 15.1 capture mode in capture mode, ccprxh:ccprxl captures the 16-bit value of the tmr1 register when an event occurs on pin ccpx. an event is defined as one of the following and is configured by the ccpxm<3:0> bits of the ccpxcon register: ? every falling edge ? every rising edge ? every 4th rising edge ? every 16th rising edge when a capture is made, the interrupt request flag bit ccpxif of the pirx register is set. the interrupt flag must be cleared in software. if another capture occurs before the value in the ccprxh, ccprxl register pair is read, the old captured value is overwritten by the new captured value (refer to figure 15-1). 15.1.1 ccpx pin configuration in capture mode, the ccpx pin should be configured as an input by setting the associated tris control bit. either rc1 or rb3 can be selected as the ccp2 pin. refer to section 6.1 ?alternate pin function? for more information. figure 15-1: capture mode operation block diagram 15.1.2 timer1 mode selection timer1 must be running in timer mode or synchronized counter mode for the ccp module to use the capture feature. in asynchronous counter mode or when timer1 is clocked at f osc , the capture operation may not work. 15.1.3 software interrupt when the capture mode is changed, a false capture interrupt may be generated. the user should keep the ccpxie interrupt enable bit of the piex register clear to avoid false interrupts. additionally, the user should clear the ccpxif interrupt flag bit of the pirx register following any change in operating mode. 15.1.4 ccp prescaler there are four prescaler settings specified by the ccpxm<3:0> bits of the ccpxcon register. whenever the ccp module is turned off, or the ccp module is not in capture mode, the prescaler counter is cleared. any reset will clear the prescaler counter. switching from one capture prescaler to another does not clear the prescaler and may generate a false interrupt. to avoid this unexpected operation, turn the module off by clearing the ccpxcon register before changing the prescaler (refer to example 15-1). example 15-1: changing between capture prescalers 15.1.5 capture during sleep capture mode depends upon the timer1 module for proper operation. there are two options for driving the timer1 module in capture mode. it can be driven by the instruction clock (f osc /4), or by an external clock source. if timer1 is clocked by f osc /4, then timer1 will not increment during sleep. when the device wakes from sleep, timer1 will continue from its previous state. if timer1 is clocked by an external clock source, then capture mode will operate as defined in section 15.1 ?capture mode? . note: if the ccpx pin is configured as an output, a write to the port can cause a capture condition. ccprxh ccprxl tmr1h tmr1l set flag bit ccpxif (pirx register) capture enable ccpxcon<3:0> prescaler ? 1, 4, 16 and edge detect ccpx system clock (f osc ) note: clocking timer1 from the system clock (f osc ) should not be used in capture mode. in order for capture mode to recognize the trigger event on the ccpx pin, timer1 must be clocked from the instruction clock (f osc /4) or from an external clock source. banksel ccp1con ;set bank bits to point ;to ccp1con clrf ccp1con ;turn ccp module off movlw new_capt_ps ;load the w reg with ; the new prescaler ; move value and ccp on movwf ccp1con ;load ccp1con with this ; value
pic16f/lf722a/723a ds41417a-page 126 ? 2010 microchip technology inc. table 15-3: summary of registers associated with capture name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 --11 1111 --11 1111 apfcon ? ? ? ? ? ? sssel ccp2sel ---- --00 ---- --00 ccp1con ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 --00 0000 ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 --00 0000 ccprxl capture/compare/pwm register x low byte xxxx xxxx uuuu uuuu ccprxh capture/compare/pwm register x high byte xxxx xxxx uuuu uuuu intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pie2 ? ? ? ? ? ? ? ccp2ie ---- ---0 ---- ---0 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pir2 ? ? ? ? ? ? ? ccp2if ---- ---0 ---- ---0 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 0000 00-0 uuuu uu-u t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/ done t1gval t1gss1 t1gss0 0000 0x00 0000 0x00 tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 legend: - = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the capture.
? 2010 microchip technology inc. ds41417a-page 127 pic16f/lf722a/723a 15.2 compare mode in compare mode, the 16-bit ccprx register value is constantly compared against the tmr1 register pair value. when a match occurs, the ccpx module may: ? toggle the ccpx output ? set the ccpx output ? clear the ccpx output ? generate a special event trigger ? generate a software interrupt the action on the pin is based on the value of the ccpxm<3:0> control bits of the ccpxcon register. all compare modes can generate an interrupt. figure 15-2: compare mode operation block diagram 15.2.1 ccpx pin configuration the user must configure the ccpx pin as an output by clearing the associated tris bit. either rc1 or rb3 can be selected as the ccp2 pin. refer to section 6.1 ?alternate pin function? for more information. 15.2.2 timer1 mode selection in compare mode, timer1 must be running in either timer mode or synchronized counter mode. the compare operation may not work in asynchronous counter mode. 15.2.3 software interrupt mode when software interrupt mode is chosen (ccpxm<3:0> = 1010 ), the ccpxif bit in the pirx register is set and the ccpx module does not assert control of the ccpx pin (refer to the ccpxcon register). 15.2.4 special event trigger when special event trigger mode is chosen (ccpxm<3:0> = 1011 ), the ccpx module does the following: ? resets timer1 ? starts an adc conversion if adc is enabled (ccp2 only) the ccpx module does not assert control of the ccpx pin in this mode (refer to the ccpxcon register). the special event trigger output of the ccp occurs immediately upon a match between the tmr1h, tmr1l register pair and the ccprxh, ccprxl register pair. the tmr1h, tmr1l register pair is not reset until the next rising edge of the timer1 clock. this allows the ccprxh, ccprxl register pair to effectively provide a 16-bit programmable period register for timer1. 15.2.5 compare during sleep the compare mode is dependent upon the system clock (f osc ) for proper operation. since f osc is shut down during sleep mode, the compare mode will not function properly during sleep. note: clearing the ccpxcon register will force the ccpx compare output latch to the default low level. this is not the port i/o data latch. ccprxh ccprxl tmr1h tmr1l comparator qs r output logic special event trigger set ccpxif interrupt flag (pirx) match tris ccpxcon<3:0> mode select output enable special event trigger will: ? clear tmr1h and tmr1l registers. ? not set interrupt flag bit tmr1if of the pir1 register. ? set the go/done bit to start the adc conversion (ccp2 only). ccpx 4 note: clocking timer1 from the system clock (f osc ) should not be used in compare mode. for the compare operation of the tmr1 register to the ccprx register to occur, timer1 must be clocked from the instruction clock (f osc /4) or from an external clock source. note 1: the special event trigger from the ccp module does not set interrupt flag bit tmr1if of the pir1 register. 2: removing the match condition by changing the contents of the ccprxh and ccprxl register pair, between the clock edge that generates the special event trigger and the clock edge that generates the timer1 reset, will preclude the reset from occurring.
pic16f/lf722a/723a ds41417a-page 128 ? 2010 microchip technology inc. table 15-4: summary of register s associated with compare name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets adcon0 ? ? chs3 chs2 chs1 chs0 go/done adon --00 0000 --00 0000 anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 --11 1111 --11 1111 apfcon ? ? ? ? ? ? sssel ccp2sel ---- --00 ---- --00 ccp1con ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 --00 0000 ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 --00 0000 ccprxl capture/compare/pwm register x low byte xxxx xxxx uuuu uuuu ccprxh capture/compare/pwm register x high byte xxxx xxxx uuuu uuuu intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pie2 ? ? ? ? ? ? ? ccp2ie ---- ---0 ---- ---0 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pir2 ? ? ? ? ? ? ? ccp2if ---- ---0 ---- ---0 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 0000 00-0 uuuu uu-u t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/ done t1gval t1gss1 t1gss0 0000 0x00 0000 0x00 tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 legend: - = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the compare.
? 2010 microchip technology inc. ds41417a-page 129 pic16f/lf722a/723a 15.3 pwm mode the pwm mode generates a pulse-width modulated signal on the ccpx pin. the duty cycle, period and resolution are determined by the following registers: ?pr2 ?t2con ? ccprxl ? ccpxcon in pulse-width modulation (pwm) mode, the ccp module produces up to a 10-bit resolution pwm output on the ccpx pin. figure 15-3 shows a simplified block diagram of pwm operation. figure 15-4 shows a typical waveform of the pwm signal. for a step-by-step procedure on how to set up the ccp module for pwm operation, refer to section 15.3.8 ?setup for pwm operation? . figure 15-3: simplified pwm block diagram the pwm output (figure 15-4) has a time base (period) and a time that the output stays high (duty cycle). figure 15-4: ccp pwm output 15.3.1 ccpx pin configuration in pwm mode, the ccpx pin is multiplexed with the port data latch. the user must configure the ccpx pin as an output by clearing the associated tris bit. either rc1 or rb3 can be selected as the ccp2 pin. refer to section 6.1 ?alternate pin function? for more information. ccprxl ccpr x h (2) (slave) comparator tmr2 pr2 (1) rq s duty cycle registers ccpxcon<5:4> clear timer2, toggle ccp x pin and latch duty cycle note 1: the 8-bit timer tmr2 register is concatenated with the 2-bit internal system clock (f osc ), or 2 bits of the prescaler, to create the 10-bit time base. 2: in pwm mode, ccprxh is a read-only register. tris ccpx comparator note: clearing the ccpxcon register will relinquish ccpx control of the ccpx pin. period pulse width tmr2 = 0 tmr2 = ccprxl:ccpxcon<5:4> tmr2 = pr2
pic16f/lf722a/723a ds41417a-page 130 ? 2010 microchip technology inc. 15.3.2 pwm period the pwm period is specified by the pr2 register of timer2. the pwm period can be calculated using the formula of equation 15-1. equation 15-1: pwm period when tmr2 is equal to pr2, the following three events occur on the next increment cycle: ? tmr2 is cleared ? the ccpx pin is set. (exception: if the pwm duty cycle = 0%, the pin will not be set.) ? the pwm duty cycle is latched from ccprxl into ccprxh. 15.3.3 pwm duty cycle the pwm duty cycle is specified by writing a 10-bit value to multiple registers: ccprxl register and dcxb<1:0> bits of the ccpxcon register. the ccprxl contains the eight msbs and the dcxb<1:0> bits of the ccpxcon register contain the two lsbs. ccprxl and dcxb<1:0> bits of the ccpxcon register can be written to at any time. the duty cycle value is not latched into ccprxh until after the period completes (i.e., a match between pr2 and tmr2 registers occurs). while using the pwm, the ccprxh register is read-only. equation 15-2 is used to calculate the pwm pulse width. equation 15-3 is used to calculate the pwm duty cycle ratio. equation 15-2: pulse width equation 15-3: duty cycle ratio the ccprxh register and a 2-bit internal latch are used to double buffer the pwm duty cycle. this double buffering is essential for glitchless pwm operation. the 8-bit timer tmr2 register is concatenated with either the 2-bit internal system clock (f osc ), or 2 bits of the prescaler, to create the 10-bit time base. the system clock is used if the timer2 prescaler is set to 1:1. when the 10-bit time base matches the ccprxh and 2-bit latch, then the ccpx pin is cleared (refer to figure 15-3). note: the timer2 postscaler (refer to section 13.1 ?timer2 operation? ) is not used in the determination of the pwm frequency. pwm period pr2 ?? 1 + ?? 4t osc ? ? ? = (tmr2 prescale value) note: t osc = 1/f osc pulse width ccprxl:ccpxcon<5:4> ?? ? = t osc ? (tmr2 prescale value) note: t osc = 1/f osc duty cycle ratio ccprxl:ccpxcon<5:4> ?? 4pr2 1 + ?? ---------------------------------------------------------------------- - =
? 2010 microchip technology inc. ds41417a-page 131 pic16f/lf722a/723a 15.3.4 pwm resolution the resolution determines the number of available duty cycles for a given period. for example, a 10-bit resolution will result in 1024 discrete duty cycles, whereas an 8-bit resolution will result in 256 discrete duty cycles. the maximum pwm resolution is 10 bits when pr2 is 255. the resolution is a function of the pr2 register value as shown by equation 15-4. equation 15-4: pwm resolution table 15-5: example pwm frequencies and resolutions (f osc = 20 mhz) table 15-6: example pwm frequencies and resolutions (f osc = 8 mhz) 15.3.5 operation in sleep mode in sleep mode, the tmr2 register will not increment and the state of the module will not change. if the ccpx pin is driving a value, it will continue to drive that value. when the device wakes up, tmr2 will continue from its previous state. 15.3.6 changes in system clock frequency the pwm frequency is derived from the system clock frequency (f osc ). any changes in the system clock fre- quency will result in changes to the pwm frequency. refer to section 7.0 ?oscillator module? for additional details. 15.3.7 effects of reset any reset will force all ports to input mode and the ccp registers to their reset states. 15.3.8 setup for pwm operation the following steps should be taken when configuring the ccp module for pwm operation: 1. disable the pwm pin (ccpx) output driver(s) by setting the associated tris bit(s). 2. load the pr2 register with the pwm period value. 3. configure the ccp module for the pwm mode by loading the ccpxcon register with the appropriate values. 4. load the ccprxl register and the dcxbx bits of the ccpxcon register, with the pwm duty cycle value. 5. configure and start timer2: ? clear the tmr2if interrupt flag bit of the pir1 register. see note below. ? configure the t2ckps bits of the t2con register with the timer2 prescale value. ? enable timer2 by setting the tmr2on bit of the t2con register. 6. enable pwm output pin: ? wait until timer2 overflows, tmr2if bit of the pir1 register is set. see note below. ? enable the pwm pin (ccpx) output driver(s) by clearing the associated tris bit(s). note: if the pulse width value is greater than the period the assigned pwm pin(s) will remain unchanged. resolution 4pr2 1 + ?? ?? log 2 ?? log ----------------------------------------- - bits = pwm frequency 1.22 khz 4.88 khz 19.53 khz 78.12 khz 156.3 khz 208.3 khz timer prescale (1, 4, 16) 16 4 1 1 1 1 pr2 value 0xff 0xff 0xff 0x3f 0x1f 0x17 maximum resolution (bits) 10 10 10 8 7 6.6 pwm frequency 1.22 khz 4.90 khz 19.61 khz 76.92 khz 153.85 khz 200.0 khz timer prescale (1, 4, 16) 16 4 1 1 1 1 pr2 value 0x65 0x65 0x65 0x19 0x0c 0x09 maximum resolution (bits) 8 8 8 6 5 5 note: in order to send a complete duty cycle and period on the first pwm output, the above steps must be included in the setup sequence. if it is not critical to start with a complete pwm signal on the first output, then step 6 may be ignored.
pic16f/lf722a/723a ds41417a-page 132 ? 2010 microchip technology inc. table 15-7: summary of registers associated with pwm name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 --11 1111 --11 1111 apfcon ? ? ? ? ? ? sssel ccp2sel ---- --00 ---- --00 ccp1con ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 --00 0000 ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 --00 0000 ccprxl capture/compare/pwm register x low byte xxxx xxxx uuuu uuuu ccprxh capture/compare/pwm register x high byte xxxx xxxx uuuu uuuu pr2 timer2 period register 1111 1111 1111 1111 t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 tmr2 timer2 module register 0000 0000 0000 0000 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 legend: - = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the pwm.
? 2010 microchip technology inc. ds41417a-page 133 pic16f/lf722a/723a 16.0 addressable universal synchronous asynchronous receiver transmitter (ausart) the addressable universal synchronous asynchronous receiver transmitter (ausart) module is a serial i/o communications peripheral. it contains all the clock generators, shift registers and data buffers necessary to perform an input or output serial data transfer independent of device program execution. the ausart, also known as a serial communications interface (sci), can be configured as a full-duplex asynchronous system or half-duplex synchronous system. full-duplex mode is useful for communications with peripheral systems, such as crt terminals and personal computers. half-duplex synchronous mode is intended for communications with peripheral devices, such as a/d or d/a integrated circuits, serial eeproms or other microcontrollers. these devices typically do not have internal clocks for baud rate generation and require the external clock signal provided by a master synchronous device. the ausart module includes the following capabilities: ? full-duplex asynchronous transmit and receive ? two-character input buffer ? one-character output buffer ? programmable 8-bit or 9-bit character length ? address detection in 9-bit mode ? input buffer overrun error detection ? received character framing error detection ? half-duplex synchronous master ? half-duplex synchronous slave ? sleep operation block diagrams of the ausart transmitter and receiver are shown in figure 16-1 and figure 16-2. figure 16-1: ausart transmit block diagram txif txie interrupt txen tx9d msb lsb data bus txreg register transmit shift register (tsr) (8) 0 tx9 trmt spen tx/ck pin buffer and control 8 spbrg f osc n n + 1 multiplier x4 x16 x64 sync 100 brgh x10 baud rate generator ???
pic16f/lf722a/723a ds41417a-page 134 ? 2010 microchip technology inc. figure 16-2: ausart recei ve block diagram the operation of the ausart module is controlled through two registers: ? transmit status and control (txsta) ? receive status and control (rcsta) these registers are detailed in register 16-1 and register 16-2, respectively. rx/dt pin buffer and control spen data recovery cren oerr ferr rsr register msb lsb rx9d rcreg register fifo interrupt rcif rcie data bus 8 stop start (8) 7 1 0 rx9 ? ? ? spbrg f osc n n + 1 multiplier x4 x16 x64 sync 100 brgh x10 baud rate generator
? 2010 microchip technology inc. ds41417a-page 135 pic16f/lf722a/723a 16.1 ausart asynchronous mode the ausart transmits and receives data using the standard non-return-to-zero (nrz) format. nrz is implemented with two levels: a v oh mark state which represents a ? 1 ? data bit, and a v ol space state which represents a ? 0 ? data bit. nrz refers to the fact that consecutively transmitted data bits of the same value stay at the output level of that bit without returning to a neutral level between each bit transmission. an nrz transmission port idles in the mark state. each character transmission consists of one start bit followed by eight or nine data bits and is always terminated by one or more stop bits. the start bit is always a space and the stop bits are always marks. the most common data format is 8 bits. each transmitted bit persists for a period of 1/(baud rate). an on-chip dedicated 8-bit baud rate generator is used to derive standard baud rate frequencies from the system oscillator. refer to table 16-5 for examples of baud rate configurations. the ausart transmits and receives the lsb first. the ausart?s transmitter and receiver are functionally independent, but share the same data format and baud rate. parity is not supported by the hardware, but can be implemented in software and stored as the ninth data bit. 16.1.1 ausart asynchronous transmitter the ausart transmitter block diagram is shown in figure 16-1. the heart of the transmitter is the serial transmit shift register (tsr), which is not directly accessible by software. the tsr obtains its data from the transmit buffer, which is the txreg register. 16.1.1.1 enabling the transmitter the ausart transmitter is enabled for asynchronous operations by configuring the following three control bits: ?txen = 1 ? sync = 0 ? spen = 1 all other ausart control bits are assumed to be in their default state. setting the txen bit of the txsta register enables the transmitter circuitry of the ausart. clearing the sync bit of the txsta register configures the ausart for asynchronous operation. setting the spen bit of the rcsta register enables the ausart and automatically configures the tx/ck i/o pin as an output. 16.1.1.2 transmitting data a transmission is initiated by writing a character to the txreg register. if this is the first character, or the previous character has been completely flushed from the tsr, the data in the txreg is immediately transferred to the tsr register. if the tsr still contains all or part of a previous character, the new character data is held in the txreg until the stop bit of the previous character has been transmitted. the pending character in the txreg is then transferred to the tsr in one t cy immediately following the stop bit transmission. the transmission of the start bit, data bits and stop bit sequence commences immediately following the transfer of the data to the tsr from the txreg. 16.1.1.3 transmit interrupt flag the txif interrupt flag bit of the pir1 register is set whenever the ausart transmitter is enabled and no character is being held for transmission in the txreg. in other words, the txif bit is only clear when the tsr is busy with a character and a new character has been queued for transmission in the txreg. the txif flag bit is not cleared immediately upon writing txreg. txif becomes valid in the second instruction cycle following the write execution. polling txif immediately following the txreg write will return invalid results. the txif bit is read-only, it cannot be set or cleared by software. the txif interrupt can be enabled by setting the txie interrupt enable bit of the pie1 register. however, the txif flag bit will be set whenever the txreg is empty, regardless of the state of txie enable bit. to use interrupts when transmitting data, set the txie bit only when there is more data to send. clear the txie interrupt enable bit upon writing the last character of the transmission to the txreg. note 1: when the spen bit is set the rx/dt i/o pin is automatically configured as an input, regardless of the state of the corresponding tris bit and whether or not the ausart receiver is enabled. the rx/dt pin data can be read via a normal port read but port latch data output is precluded. 2: the txif transmitter interrupt flag is set when the txen enable bit is set.
pic16f/lf722a/723a ds41417a-page 136 ? 2010 microchip technology inc. 16.1.1.4 tsr status the trmt bit of the txsta register indicates the status of the tsr register. this is a read-only bit. the trmt bit is set when the tsr register is empty and is cleared when a character is transferred to the tsr register from the txreg. the trmt bit remains clear until all bits have been shifted out of the tsr register. no interrupt logic is tied to this bit, so the user has to poll this bit to determine the tsr status. 16.1.1.5 transmitting 9-bit characters the ausart supports 9-bit character transmissions. when the tx9 bit of the txsta register is set, the ausart will shift 9 bits out for each character transmit- ted. the tx9d bit of the txsta register is the ninth, and most significant, data bit. when transmitting 9-bit data, the tx9d data bit must be written before writing the 8 least significant bits into the txreg. all nine bits of data will be transferred to the tsr shift register immediately after the txreg is written. a special 9-bit address mode is available for use with multiple receivers. refer to section 16.1.2.7 ?address detection? for more information on the address mode. 16.1.1.6 asynchronous transmission set-up: 1. initialize the spbrg register and the brgh bit to achieve the desired baud rate (refer to section 16.2 ?ausart baud rate generator (brg)? ). 2. enable the asynchronous serial port by clearing the sync bit and setting the spen bit. 3. if 9-bit transmission is desired, set the tx9 con- trol bit. a set ninth data bit will indicate that the 8 least significant data bits are an address when the receiver is set for address detection. 4. enable the transmission by setting the txen control bit. this will cause the txif interrupt bit to be set. 5. if interrupts are desired, set the txie interrupt enable bit of the pie1 register. an interrupt will occur immediately provided that the gie and peie bits of the intcon register are also set. 6. if 9-bit transmission is selected, the ninth bit should be loaded into the tx9d data bit. 7. load 8-bit data into the txreg register. this will start the transmission. figure 16-3: asynchronous transmission figure 16-4: asynchronous transmiss ion (back-to-back) note: the tsr register is not mapped in data memory, so it is not available to the user. word 1 stop bit word 1 transmit shift reg start bit bit 0 bit 1 bit 7/8 write to txreg word 1 brg output (shift clock) tx/ck pin txif bit (transmit buffer empty flag) trmt bit (transmit shift reg. empty flag) 1 t cy transmit shift reg. write to txreg brg output (shift clock) tx/ck pin trmt bit (transmit shift reg. empty flag) word 1 word 2 word 1 word 2 start bit stop bit start bit transmit shift reg. word 1 word 2 bit 0 bit 1 bit 7/8 bit 0 note: this timing diagram shows two consecutive transmissions. 1 t cy 1 t cy txif bit (transmit buffer empty flag)
? 2010 microchip technology inc. ds41417a-page 137 pic16f/lf722a/723a table 16-1: registers associated with asynchronous transmission name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txreg ausart transmit data register 0000 0000 0000 0000 txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for asynchronous transmission.
pic16f/lf722a/723a ds41417a-page 138 ? 2010 microchip technology inc. 16.1.2 ausart asynchronous receiver the asynchronous mode is typically used in rs-232 systems. the receiver block diagram is shown in figure 16-2. the data is received on the rx/dt pin and drives the data recovery block. the data recovery block is actually a high-speed shifter operating at 16 times the baud rate, whereas the serial receive shift register (rsr) operates at the bit rate. when all 8 or 9 bits of the character have been shifted in, they are immediately transferred to a two character first-in first-out (fifo) memory. the fifo buffering allows reception of two complete characters and the start of a third character before software must start servicing the ausart receiver. the fifo and rsr registers are not directly accessible by software. access to the received data is via the rcreg register. 16.1.2.1 enabling the receiver the ausart receiver is enabled for asynchronous operation by configuring the following three control bits: ? cren = 1 ? sync = 0 ? spen = 1 all other ausart control bits are assumed to be in their default state. setting the cren bit of the rcsta register enables the receiver circuitry of the ausart. clearing the sync bit of the txsta register configures the ausart for asynchronous operation. setting the spen bit of the rcsta register enables the ausart and automatically configures the rx/dt i/o pin as an input. 16.1.2.2 receiving data the receiver data recovery circuit initiates character reception on the falling edge of the first bit. the first bit, also known as the start bit, is always a zero. the data recovery circuit counts one-half bit time to the center of the start bit and verifies that the bit is still a zero. if it is not a zero then the data recovery circuit aborts character reception, without generating an error, and resumes looking for the falling edge of the start bit. if the start bit zero verification succeeds then the data recovery circuit counts a full bit time to the center of the next bit. the bit is then sampled by a majority detect circuit and the resulting ? 0 ? or ? 1 ? is shifted into the rsr. this repeats until all data bits have been sampled and shifted into the rsr. one final bit time is measured and the level sampled. this is the stop bit, which is always a ? 1 ?. if the data recovery circuit samples a ? 0 ? in the stop bit position then a framing error is set for this character, otherwise the framing error is cleared for this character. refer to section 16.1.2.4 ?receive framing error? for more information on framing errors. immediately after all data bits and the stop bit have been received, the character in the rsr is transferred to the ausart receive fifo and the rcif interrupt flag bit of the pir1 register is set. the top character in the fifo is transferred out of the fifo by reading the rcreg register. 16.1.2.3 receive interrupts the rcif interrupt flag bit of the pir1 register is set whenever the ausart receiver is enabled and there is an unread character in the receive fifo. the rcif interrupt flag bit is read-only, it cannot be set or cleared by software. rcif interrupts are enabled by setting all of the following bits: ? rcie, receive interrupt enable bit of the pie1 register ? peie, peripheral interrupt enable bit of the intcon register ? gie, global interrupt enable bit of the intcon register the rcif interrupt flag bit of the pir1 register will be set when there is an unread character in the fifo, regardless of the state of interrupt enable bits. note: when the spen bit is set the tx/ck i/o pin is automatically configured as an output, regardless of the state of the corresponding tris bit and whether or not the ausart transmitter is enabled. the port latch is disconnected from the output driver so it is not possible to use the tx/ck pin as a general purpose output. note: if the receive fifo is overrun, no additional characters will be received until the overrun condition is cleared. refer to section 16.1.2.5 ?receive overrun error? for more information on overrun errors.
? 2010 microchip technology inc. ds41417a-page 139 pic16f/lf722a/723a 16.1.2.4 receive framing error each character in the receive fifo buffer has a corresponding framing error status bit. a framing error indicates that a stop bit was not seen at the expected time. the framing error status is accessed via the ferr bit of the rcsta register. the ferr bit represents the status of the top unread character in the receive fifo. therefore, the ferr bit must be read before reading the rcreg. the ferr bit is read-only and only applies to the top unread character in the receive fifo. a framing error (ferr = 1 ) does not preclude reception of additional characters. it is not necessary to clear the ferr bit. reading the next character from the fifo buffer will advance the fifo to the next character and the next corresponding framing error. the ferr bit can be forced clear by clearing the spen bit of the rcsta register which resets the ausart. clearing the cren bit of the rcsta register does not affect the ferr bit. a framing error by itself does not generate an interrupt. 16.1.2.5 receive overrun error the receive fifo buffer can hold two characters. an overrun error will be generated if a third character, in its entirety, is received before the fifo is accessed. when this happens the oerr bit of the rcsta register is set. the characters already in the fifo buffer can be read but no additional characters will be received until the error is cleared. the error must be cleared by either clearing the cren bit of the rcsta register or by setting the ausart by clearing the spen bit of the rcsta register. 16.1.2.6 receiving 9-bit characters the ausart supports 9-bit character reception. when the rx9 bit of the rcsta register is set the ausart will shift 9 bits into the rsr for each character received. the rx9d bit of the rcsta register is the ninth and most significant data bit of the top unread character in the receive fifo. when reading 9-bit data from the receive fifo buffer, the rx9d data bit must be read before reading the 8 least significant bits from the rcreg. 16.1.2.7 address detection a special address detection mode is available for use when multiple receivers share the same transmission line, such as in rs-485 systems. address detection is enabled by setting the adden bit of the rcsta register. address detection requires 9-bit character reception. when address detection is enabled, only characters with the ninth data bit set will be transferred to the receive fifo buffer, thereby setting the rcif interrupt bit of the pir1 register. all other characters will be ignored. upon receiving an address character, user software determines if the address matches its own. upon address match, user software must disable address detection by clearing the adden bit before the next stop bit occurs. when user software detects the end of the message, determined by the message protocol used, software places the receiver back into the address detection mode by setting the adden bit. note: if all receive characters in the receive fifo have framing errors, repeated reads of the rcreg will not clear the ferr bit.
pic16f/lf722a/723a ds41417a-page 140 ? 2010 microchip technology inc. 16.1.2.8 asynchronous reception set-up: 1. initialize the spbrg register and the brgh bit to achieve the desired baud rate (refer to section 16.2 ?ausart baud rate generator (brg)? ). 2. enable the serial port by setting the spen bit. the sync bit must be clear for asynchronous operation. 3. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 4. if 9-bit reception is desired, set the rx9 bit. 5. enable reception by setting the cren bit. 6. the rcif interrupt flag bit of the pir1 register will be set when a character is transferred from the rsr to the receive buffer. an interrupt will be generated if the rcie bit of the pie1 register was also set. 7. read the rcsta register to get the error flags and, if 9-bit data reception is enabled, the ninth data bit. 8. get the received 8 least significant data bits from the receive buffer by reading the rcreg register. 9. if an overrun occurred, clear the oerr flag by clearing the cren receiver enable bit. 16.1.2.9 9-bit address detection mode set-up this mode would typically be used in rs-485 systems. to set up an asynchronous reception with address detect enable: 1. initialize the spbrg register and the brgh bit to achieve the desired baud rate (refer to section 16.2 ?ausart baud rate generator (brg)? ). 2. enable the serial port by setting the spen bit. the sync bit must be clear for asynchronous operation. 3. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 4. enable 9-bit reception by setting the rx9 bit. 5. enable address detection by setting the adden bit. 6. enable reception by setting the cren bit. 7. the rcif interrupt flag bit of the pir1 register will be set when a character with the ninth bit set is transferred from the rsr to the receive buffer. an interrupt will be generated if the rcie inter- rupt enable bit of the pie1 register was also set. 8. read the rcsta register to get the error flags. the ninth data bit will always be set. 9. get the received 8 least significant data bits from the receive buffer by reading the rcreg register. software determines if this is the device?s address. 10. if an overrun occurred, clear the oerr flag by clearing the cren receiver enable bit. 11. if the device has been addressed, clear the adden bit to allow all received data into the receive buffer and generate interrupts. figure 16-5: asynchronous reception start bit bit 7/8 bit 1 bit 0 bit 7/8 bit 0 stop bit start bit start bit bit 7/8 stop bit rx/dt pin reg rcv buffer reg rcv shift read rcv buffer reg rcreg rcif (interrupt flag) oerr bit cren word 1 rcreg word 2 rcreg stop bit note: this timing diagram shows three words appearing on the rx input. the rcreg (receive buffer) is read after the third word, causing the oerr (overrun) bit to be set.
? 2010 microchip technology inc. ds41417a-page 141 pic16f/lf722a/723a table 16-2: registers associated with asynchronous reception name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcreg ausart receive data register 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txsta csrc tx9 txen sync ?brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for asynchronous reception.
pic16f/lf722a/723a ds41417a-page 142 ? 2010 microchip technology inc. register 16-1: txsta: transmit status and control register r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r-1 r/w-0 csrc tx9 txen (1) sync ? brgh trmt tx9d bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 csrc: clock source select bit asynchronous mode : don?t care synchronous mode : 1 = master mode (clock generated internally from brg) 0 = slave mode (clock from external source) bit 6 tx9: 9-bit transmit enable bit 1 = selects 9-bit transmission 0 = selects 8-bit transmission bit 5 txen: transmit enable bit (1) 1 = transmit enabled 0 = transmit disabled bit 4 sync: ausart mode select bit 1 = synchronous mode 0 = asynchronous mode bit 3 unimplemented: read as ? 0 ? bit 2 brgh: high baud rate select bit asynchronous mode : 1 = high speed 0 = low speed synchronous mode: unused in this mode bit 1 trmt: transmit shift register status bit 1 = tsr empty 0 = tsr full bit 0 tx9d: ninth bit of transmit data can be address/data bit or a parity bit. note 1: sren/cren overrides txen in synchronous mode.
? 2010 microchip technology inc. ds41417a-page 143 pic16f/lf722a/723a register 16-2: rcsta: receive status and control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r-0 r-0 r-x spen rx9 sren cren adden ferr oerr rx9d bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 spen: serial port enable bit (1) 1 = serial port enabled (configures rx/dt and tx/ck pins as serial port pins) 0 = serial port disabled (held in reset) bit 6 rx9: 9-bit receive enable bit 1 = selects 9-bit reception 0 = selects 8-bit reception bit 5 sren: single receive enable bit asynchronous mode : don?t care synchronous mode ? master : 1 = enables single receive 0 = disables single receive this bit is cleared after reception is complete. synchronous mode ? slave: don?t care bit 4 cren: continuous receive enable bit asynchronous mode : 1 = enables receiver 0 = disables receiver synchronous mode : 1 = enables continuous receive until enable bit cren is cleared (cren overrides sren) 0 = disables continuous receive bit 3 adden: address detect enable bit asynchronous mode 9-bit (rx9 = 1 ) : 1 = enables address detection, enable interrupt and load the receive buffer when rsr<8> is set 0 = disables address detection, all bytes are received and ninth bit can be used as parity bit asynchronous mode 8-bit (rx9 = 0 ) : don?t care synchronous mode : must be set to ? 0 ? bit 2 ferr: framing error bit 1 = framing error (can be updated by reading rcreg register and receive next valid byte) 0 = no framing error bit 1 oerr: overrun error bit 1 = overrun error (can be cleared by clearing bit cren) 0 = no overrun error bit 0 rx9d: ninth bit of received data this can be address/data bit or a parity bit and must be calculated by user firmware. note 1: the ausart module automatically changes the pin from tri-state to drive as needed. configure trisx = 1 .
pic16f/lf722a/723a ds41417a-page 144 ? 2010 microchip technology inc. 16.2 ausart baud rate generator (brg) the baud rate generator (brg) is an 8-bit timer that is dedicated to the support of both the asynchronous and synchronous ausart operation. the spbrg register determines the period of the free running baud rate timer. in asynchronous mode the multiplier of the baud rate period is determined by the brgh bit of the txsta register. in synchronous mode, the brgh bit is ignored. table 16-3 contains the formulas for determining the baud rate. example 16-1 provides a sample calculation for determining the baud rate and baud rate error. typical baud rates and error values for various asynchronous modes have been computed for your convenience and are shown in table 16-3. it may be advantageous to use the high baud rate (brgh = 1 ), to reduce the baud rate error. writing a new value to the spbrg register causes the brg timer to be reset (or cleared). this ensures that the brg does not wait for a timer overflow before outputting the new baud rate. example 16-1: calculating baud rate error table 16-3: baud rate formulas table 16-4: registers associated with the baud rate generator for a device with f osc of 16 mhz, desired baud rate of 9600, and asynchronous mode with sync = 0 and brgh = 0 (as seen in table 16-3): solving for spbrg: spbrg f osc 64 desired baud rate ?? --------------------------------------------------------- ?? ?? 1 ? = desired baud rate f osc 64 spbrg 1 + ?? --------------------------------------- = 16000000 64 9600 ?? ------------------------ ?? ?? 1 ? = 25.042 ?? 25 == actual baud rate 16000000 64 25 1 + ?? -------------------------- - = 9615 = error actual baud rate desired baud rate ? desired baud rate ------------------------------------------------------------------------------------------------- - ?? ?? 100 = 9615 9600 ? 9600 ----------------------------- - ?? ?? 100 0.16% == % configuration bits ausart mode baud rate formula sync brgh 00 asynchronous f osc /[64 (n+1)] 01 asynchronous f osc /[16 (n+1)] 1x synchronous f osc /[4 (n+1)] legend: x = don?t care, n = value of spbrg register namebit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 0000 0000 txsta csrc tx9 txen sync ?brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for the baud rate generator.
? 2010 microchip technology inc. ds41417a-page 145 pic16f/lf722a/723a table 16-5: baud rates for asynchronous modes baud rate sync = 0 , brgh = 0 f osc = 20.000 mhz f osc = 18.432 mhz f osc = 16.0000 mhz f osc = 11.0592 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 ? ? ? ? ? ? ?? ? ?? ? 1200 1221 1.73 255 1200 0.00 239 1201 0.08 207 1200 0.00 143 2400 2404 0.16 129 2400 0.00 119 2403 0.16 103 2400 0.00 71 9600 9470 -1.36 32 9600 0.00 29 9615 0.16 25 9600 0.00 17 10417 10417 0.00 29 10286 -1.26 27 10416 -0.01 23 10165 -2.42 16 19.2k 19.53k 1.73 15 19.20k 0.00 14 19.23k 0.16 12 19.20k 0.00 8 57.6k ? ? ? 57.60k 0.00 7 ?? ? 57.60k 0.00 2 115.2k ? ? ? ? ? ? ? ? ? ? ? ? baud rate sync = 0 , brgh = 0 f osc = 8.000 mhz f osc = 4.000 mhz f osc = 3.6864 mhz f osc = 1.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 ? ? ? 300 0.16 207 300 0.00 191 300 0.16 51 1200 1202 0.16 103 1202 0.16 51 1200 0.00 47 1202 0.16 12 2400 2404 0.16 51 2404 0.16 25 2400 0.00 23 ? ? ? 9600 9615 0.16 12 ? ? ? 9600 0.00 5 ? ? ? 10417 10417 0.00 11 10417 0.00 5 ? ? ? ? ? ? 19.2k ? ? ? ? ? ? 19.20k 0.00 2 ? ? ? 57.6k ? ? ? ? ? ? 57.60k 0.00 0 ? ? ? 115.2k ? ? ? ? ? ? ? ? ? ? ? ? baud rate sync = 0 , brgh = 1 f osc = 20.000 mhz f osc = 18.432 mhz f osc = 16.0000 mhz f osc = 11.0592 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 ?? ? ?? ? ?? ? ?? ? 1200 ? ? ? ? ? ? ? ? ? ? ? ? 2400 ? ? ? ? ? ? ? ? ? ?? ? 9600 9615 0.16 129 9600 0.00 119 9615 0.16 103 9600 0.00 71 10417 10417 0.00 119 10378 -0.37 110 10417 0.00 95 10473 0.53 65 19.2k 19.23k 0.16 64 19.20k 0.00 59 19.23k 0.16 51 19.20k 0.00 35 57.6k 56.82k -1.36 21 57.60k 0.00 19 58.8k 2.12 16 57.60k 0.00 11 115.2k 113.64k -1.36 10 115.2k 0.00 9 ? ? ? 115.2k 0.00 5
pic16f/lf722a/723a ds41417a-page 146 ? 2010 microchip technology inc. baud rate sync = 0 , brgh = 1 f osc = 8.000 mhz f osc = 4.000 mhz f osc = 3.6864 mhz f osc = 1.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 ?? ? ? ? ? ? ? ? 300 0.16 207 1200 ? ? ? 1202 0.16 207 1200 0.00 191 1202 0.16 51 2400 2404 0.16 207 2404 0.16 103 2400 0.00 95 2404 0.16 25 9600 9615 0.16 51 9615 0.16 25 9600 0.00 23 ? ? ? 10417 10417 0.00 47 10417 0.00 23 10473 0.53 21 10417 0.00 5 19.2k 19231 0.16 25 19.23k 0.16 12 19.2k 0.00 11 ? ? ? 57.6k 55556 -3.55 8 ? ? ? 57.60k 0.00 3 ? ? ? 115.2k ? ? ? ? ? ? 115.2k 0.00 1 ? ? ? table 16-5: baud rates for asynchronous modes
? 2010 microchip technology inc. ds41417a-page 147 pic16f/lf722a/723a 16.3 ausart synchronous mode synchronous serial communications are typically used in systems with a single master and one or more slaves. the master device contains the necessary cir- cuitry for baud rate generation and supplies the clock for all devices in the system. slave devices can take advantage of the master clock by eliminating the internal clock generation circuitry. there are two signal lines in synchronous mode: a bidirectional data line and a clock line. slaves use the external clock supplied by the master to shift the serial data into and out of their respective receive and trans- mit shift registers. since the data line is bidirectional, synchronous operation is half-duplex only. half-duplex refers to the fact that master and slave devices can receive and transmit data but not both simultaneously. the ausart can operate as either a master or slave device. start and stop bits are not used in synchronous transmissions. 16.3.1 synchronous master mode the following bits are used to configure the ausart for synchronous master operation: ? sync = 1 ? csrc = 1 ? sren = 0 (for transmit); sren = 1 (for receive) ? cren = 0 (for transmit); cren = 1 (for receive) ? spen = 1 setting the sync bit of the txsta register configures the device for synchronous operation. setting the csrc bit of the txsta register configures the device as a master. clearing the sren and cren bits of the rcsta register ensures that the device is in the transmit mode, otherwise the device will be configured to receive. setting the spen bit of the rcsta register enables the ausart. 16.3.1.1 master clock synchronous data transfers use a separate clock line, which is synchronous with the data. a device config- ured as a master transmits the clock on the tx/ck line. the tx/ck pin output driver is automatically enabled when the ausart is configured for synchronous transmit or receive operation. serial data bits change on the leading edge to ensure they are valid at the trail- ing edge of each clock. one clock cycle is generated for each data bit. only as many clock cycles are generated as there are data bits. 16.3.1.2 synchronous master transmission data is transferred out of the device on the rx/dt pin. the rx/dt and tx/ck pin output drivers are automat- ically enabled when the ausart is configured for synchronous master transmit operation. a transmission is initiated by writing a character to the txreg register. if the tsr still contains all or part of a previous character, the new character data is held in the txreg until the last bit of the previous character has been transmitted. if this is the first character, or the previous character has been completely flushed from the tsr, the data in the txreg is immediately trans- ferred to the tsr. the transmission of the character commences immediately following the transfer of the data to the tsr from the txreg. each data bit changes on the leading edge of the master clock and remains valid until the subsequent leading clock edge. 16.3.1.3 synchronous master transmission set-up: 1. initialize the spbrg register and the brgh bit to achieve the desired baud rate (refer to section 16.2 ?ausart baud rate generator (brg)? ). 2. enable the synchronous master serial port by setting bits sync, spen and csrc. 3. disable receive mode by clearing bits sren and cren. 4. enable transmit mode by setting the txen bit. 5. if 9-bit transmission is desired, set the tx9 bit. 6. if interrupts are desired, set the txie bit of the pie1 register and the gie and peie bits of the intcon register. 7. if 9-bit transmission is selected, the ninth bit should be loaded in the tx9d bit. 8. start transmission by loading data to the txreg register. note: the tsr register is not mapped in data memory, so it is not available to the user.
pic16f/lf722a/723a ds41417a-page 148 ? 2010 microchip technology inc. figure 16-6: synchronous t ransmission figure 16-7: synchronous transmission (through txen) table 16-6: registers associated wi th synchronous master transmission name bit 7 bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txreg ausart transmit data register 0000 0000 0000 0000 txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for synchronous master transmission. bit 0 bit 1 bit 7 word 1 bit 2 bit 0 bit 1 bit 7 rx/dt write to txreg reg txif bit (interrupt flag) txen bit ? 1 ? ? 1 ? word 2 trmt bit write word 1 write word 2 note: synchronous master mode, spbrg = 0 , continuous transmission of two 8-bit words. pin tx/ck pin rx/dt pin tx/ck pin write to txreg reg txif bit trmt bit bit 0 bit 1 bit 2 bit 6 bit 7 txen bit
? 2010 microchip technology inc. ds41417a-page 149 pic16f/lf722a/723a 16.3.1.4 synchronous master reception data is received at the rx/dt pin. the rx/dt pin output driver is automatically disabled when the ausart is configured for synchronous master receive operation. in synchronous mode, reception is enabled by setting either the single receive enable bit (sren of the rcsta register) or the continuous receive enable bit (cren of the rcsta register). when sren is set and cren is clear, only as many clock cycles are generated as there are data bits in a single character. the sren bit is automatically cleared at the completion of one character. when cren is set, clocks are continuously generated until cren is cleared. if cren is cleared in the middle of a character the ck clock stops immediately and the partial charac- ter is discarded. if sren and cren are both set, then sren is cleared at the completion of the first character and cren takes precedence. to initiate reception, set either sren or cren. data is sampled at the rx/dt pin on the trailing edge of the tx/ck clock pin and is shifted into the receive shift register (rsr). when a complete character is received into the rsr, the rcif bit of the pir1 register is set and the character is automatically transferred to the two character receive fifo. the least significant eight bits of the top character in the receive fifo are available in rcreg. the rcif bit remains set as long as there are un-read characters in the receive fifo. 16.3.1.5 slave clock synchronous data transfers use a separate clock line, which is synchronous with the data. a device configured as a slave receives the clock on the tx/ck line. the tx/ ck pin output driver is automatically disabled when the device is configured for synchronous slave transmit or receive operation. serial data bits change on the leading edge to ensure they are valid at the trailing edge of each clock. one data bit is transferred for each clock cycle. only as many clock cycles should be received as there are data bits. 16.3.1.6 receive overrun error the receive fifo buffer can hold two characters. an overrun error will be generated if a third character, in its entirety, is received before rcreg is read to access the fifo. when this happens the oerr bit of the rcsta register is set. previous data in the fifo will not be overwritten. the two characters in the fifo buffer can be read, however, no additional characters will be received until the error is cleared. the oerr bit can only be cleared by clearing the overrun condition. if the overrun error occurred when the sren bit is set and cren is clear then the error is cleared by reading rcreg. if the overrun occurred when the cren bit is set then the error condition is cleared by either clearing the cren bit of the rcsta register. 16.3.1.7 receiving 9-bit characters the ausart supports 9-bit character reception. when the rx9 bit of the rcsta register is set, the ausart will shift 9-bits into the rsr for each character received. the rx9d bit of the rcsta register is the ninth, and most significant, data bit of the top unread character in the receive fifo. when reading 9-bit data from the receive fifo buffer, the rx9d data bit must be read before reading the 8 least significant bits from the rcreg. address detection in synchronous modes is not supported, therefore the adden bit of the rcsta register must be cleared. 16.3.1.8 synchronous master reception set- up: 1. initialize the spbrg register for the appropriate baud rate. set or clear the brgh bit, as required, to achieve the desired baud rate. 2. enable the synchronous master serial port by setting bits sync, spen and csrc. 3. ensure bits cren and sren are clear. 4. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 5. if 9-bit reception is desired, set bit rx9. 6. verify address detection is disabled by clearing the adden bit of the rcsta register. 7. start reception by setting the sren bit or for continuous reception, set the cren bit. 8. interrupt flag bit rcif of the pir1 register will be set when reception of a character is complete. an interrupt will be generated if the rcie inter- rupt enable bit of the pie1 register was set. 9. read the rcsta register to get the ninth bit (if enabled) and determine if any error occurred during reception. 10. read the 8-bit received data by reading the rcreg register. 11. if an overrun error occurs, clear the error by either clearing the cren bit of the rcsta register or by clearing the spen bit, which resets the ausart.
pic16f/lf722a/723a ds41417a-page 150 ? 2010 microchip technology inc. figure 16-8: synchronous reception (master mode, sren) table 16-7: registers associated with synchronous master reception name bit 7 bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcreg ausart receive data register 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txsta csrc tx9 txen sync ?brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for synchronous master reception. cren bit rx/dt write to bit sren sren bit rcif bit (interrupt) read rcreg ? 0 ? bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 ? 0 ? note: timing diagram demonstrates synchronous master mode with bit sren = 1 and bit brgh = 0 . tx/ck pin pin
? 2010 microchip technology inc. ds41417a-page 151 pic16f/lf722a/723a 16.3.2 synchronous slave mode the following bits are used to configure the ausart for synchronous slave operation: ? sync = 1 ? csrc = 0 ? sren = 0 (for transmit); sren = 1 (for receive) ? cren = 0 (for transmit); cren = 1 (for receive) ? spen = 1 setting the sync bit of the txsta register configures the device for synchronous operation. clearing the csrc bit of the txsta register configures the device as a slave. clearing the sren and cren bits of the rcsta register ensures that the device is in the transmit mode, otherwise the device will be configured to receive. setting the spen bit of the rcsta register enables the ausart. 16.3.2.1 ausart synchronous slave transmit the operation of the synchronous master and slave modes are identical (refer to section 16.3.1.2 ?synchronous master transmission?) , except in the case of the sleep mode. if two words are written to the txreg and then the sleep instruction is executed, the following will occur: 1. the first character will immediately transfer to the tsr register and transmit. 2. the second word will remain in txreg register. 3. the txif bit will not be set. 4. after the first character has been shifted out of tsr, the txreg register will transfer the second character to the tsr and the txif bit will now be set. 5. if the peie and txie bits are set, the interrupt will wake the device from sleep and execute the next instruction. if the gie bit is also set, the program will call the interrupt service routine. 16.3.2.2 synchronous slave transmission set-up: 1. set the sync and spen bits and clear the csrc bit. 2. clear the cren and sren bits. 3. if using interrupts, ensure that the gie and peie bits of the intcon register are set and set the txie bit. 4. if 9-bit transmission is desired, set the tx9 bit. 5. enable transmission by setting the txen bit. 6. verify address detection is disabled by clearing the adden bit of the rcsta register. 7. if 9-bit transmission is selected, insert the most significant bit into the tx9d bit. 8. start transmission by writing the least significant 8 bits to the txreg register. table 16-8: registers associated with synchronous slave transmission name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txreg ausart transmit data register 0000 0000 0000 0000 txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used fo r synchronous slave transmission.
pic16f/lf722a/723a ds41417a-page 152 ? 2010 microchip technology inc. 16.3.2.3 ausart synchronous slave reception the operation of the synchronous master and slave modes is identical ( section 16.3.1.4 ?synchronous master reception? ), with the following exceptions: ? sleep ? cren bit is always set, therefore the receiver is never idle ? sren bit, which is a ?don?t care? in slave mode a character may be received while in sleep mode by setting the cren bit prior to entering sleep. once the word is received, the rsr register will transfer the data to the rcreg register. if the rcie interrupt enable bit of the pie1 register is set, the interrupt generated will wake the device from sleep and execute the next instruction. if the gie bit is also set, the program will branch to the interrupt vector. 16.3.2.4 synchronous slave reception set- up: 1. set the sync and spen bits and clear the csrc bit. 2. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 3. if 9-bit reception is desired, set the rx9 bit. 4. verify address detection is disabled by clearing the adden bit of the rcsta register. 5. set the cren bit to enable reception. 6. the rcif bit of the pir1 register will be set when reception is complete. an interrupt will be generated if the rcie bit of the pie1 register was set. 7. if 9-bit mode is enabled, retrieve the most significant bit from the rx9d bit of the rcsta register. 8. retrieve the 8 least significant bits from the receive fifo by reading the rcreg register. 9. if an overrun error occurs, clear the error by either clearing the cren bit of the rcsta register. table 16-9: registers associated with synchronous slave reception name bit 7 bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcreg ausart receive data register 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used fo r synchronous slave reception.
? 2010 microchip technology inc. ds41417a-page 153 pic16f/lf722a/723a 16.4 ausart operation during sleep the ausart will remain active during sleep only in the synchronous slave mode. all other modes require the system clock and therefore can not generate the necessary signals to run the transmit or receive shift registers during sleep. synchronous slave mode uses an externally generated clock to run the transmit and receive shift registers. 16.4.1 synchronous receive during sleep to receive during sleep, all the following conditions must be met before entering sleep mode: ? rcsta and txsta control registers must be configured for synchronous slave reception (refer to section 16.3.2.4 ?synchronous slave reception set-up:? ). ? if interrupts are desired, set the rcie bit of the pie1 register and the peie bit of the intcon register. ? the rcif interrupt flag must be cleared by read- ing rcreg to unload any pending characters in the receive buffer. upon entering sleep mode, the device will be ready to accept data and clocks on the rx/dt and tx/ck pins, respectively. when the data word has been completely clocked in by the external device, the rcif interrupt flag bit of the pir1 register will be set, thereby waking the processor from sleep. upon waking from sleep, the instruction following the sleep instruction will be executed. if the global interrupt enable (gie) bit of the intcon register is also set, then the interrupt service routine at address 0004h will be called. 16.4.2 synchronous transmit during sleep to transmit during sleep, all the following conditions must be met before entering sleep mode: ? rcsta and txsta control registers must be configured for synchronous slave transmission (refer to section 16.3.2.2 ?synchronous slave transmission set-up:? ). ? the txif interrupt flag must be cleared by writing the output data to the txreg, thereby filling the tsr and transmit buffer. ? if interrupts are desired, set the txie bit of the pie1 register and the peie bit of the intcon register. upon entering sleep mode, the device will be ready to accept clocks on tx/ck pin and transmit data on the rx/dt pin. when the data word in the tsr has been completely clocked out by the external device, the pending byte in the txreg will transfer to the tsr and the txif flag will be set, thereby waking the processor from sleep. at this point, the txreg is available to accept another character for transmission, which will clear the txif flag. upon waking from sleep, the instruction following the sleep instruction will be executed. if the global interrupt enable (gie) bit is also set then the interrupt service routine at address 0004h will be called.
pic16f/lf722a/723a ds41417a-page 154 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 155 pic16f/lf722a/723a 17.0 ssp module overview the synchronous serial port (ssp) module is a serial interface useful for communicating with other peripher- als or microcontroller devices. these peripheral devices may be serial eeproms, shift registers, dis- play drivers, a/d converters, etc. the ssp module can operate in one of two modes: ? serial peripheral interface (spi) ? inter-integrated circuit (i 2 c?) 17.1 spi mode the spi mode allows 8 bits of data to be synchronously transmitted and received, simultaneously. the ssp module can be operated in one of two spi modes: ?master mode ? slave mode spi is a full-duplex protocol, with all communication being bidirectional and initiated by a master device. all clocking is provided by the master device and all bits are transmitted, msb first. care must be taken to ensure that all devices on the spi bus are setup to allow all controllers to send and receive data at the same time. a typical spi connection between microcontroller devices is shown in figure 17-1. addressing of more than one slave device is accomplished via multiple hardware slave select lines. external hardware and additional i/o pins must be used to support multiple slave select addressing. this prevents extra overhead in software for communication. for spi communication, typically three pins are used: ? serial data out (sdo) ? serial data in (sdi) ? serial clock (sck) additionally, a fourth pin may be used when in a slave mode of operation: ? slave select (ss ) figure 17-1: typical spi mast er/slave connection serial input buffer (sspbuf) shift register (sspsr) msb lsb sdo sdi processor 1 sck spi master sspm<3:0> = 00xx serial input buffer (sspbuf) shift register (sspsr) lsb msb sdi sdo processor 2 sck spi slave sspm<3:0> = 010x serial clock ss slave select general i/o (optional)
pic16f/lf722a/723a ds41417a-page 156 ? 2010 microchip technology inc. figure 17-2: spi mode block diagram read write internal data bus sdi sdo ra5/ss sck sspsr reg sspbuf reg sspm<3:0> bit 0 shift clock ss control enable edge select clock select tmr2 f osc prescaler 4, 16, 64 trisx 2 4 ra0/ss sssel output ? 2 edge select bit 7
? 2010 microchip technology inc. ds41417a-page 157 pic16f/lf722a/723a 17.1.1 master mode in master mode, data transfer can be initiated at any time because the master controls the sck line. master mode determines when the slave (figure 17-1, processor 2) transmits data via control of the sck line. 17.1.1.1 master mode operation the ssp consists of a transmit/receive shift register (sspsr) and a buffer register (sspbuf). the sspsr register shifts the data in and out of the device, msb first. the sspbuf register holds the data that is written out of the master until the received data is ready. once the eight bits of data have been received, the byte is moved to the sspbuf register. the buffer full status bit, bf of the sspstat register, and the ssp interrupt flag bit, sspif of the pir1 register, are then set. any write to the sspbuf register during transmission/ reception of data will be ignored and the write collision detect bit, wcol of the sspcon register, will be set. user software must clear the wcol bit so that it can be determined if the following write(s) to the sspbuf register completed successfully. when the application software is expecting to receive valid data, the sspbuf should be read before the next byte of data is written to the sspbuf. the bf bit of the sspstat register is set when sspbuf has been loaded with the received data (transmission is complete). when the sspbuf is read, the bf bit is cleared. this data may be irrelevant if the spi is only a transmitter. the ssp interrupt may be used to determine when the transmission/reception is complete and the sspbuf must be read and/or written. if interrupts are not used, then software polling can be done to ensure that a write collision does not occur. example 17-1 shows the loading of the sspbuf (sspsr) for data transmission. 17.1.1.2 enabling master i/o to enable the serial port, the sspen bit of the sspcon register, must be set. to reset or reconfigure spi mode, clear the sspen bit, re-initialize the sspcon register and then set the sspen bit. if a master mode of operation is selected in the sspm bits of the sspcon register, the sdi, sdo and sck pins will be assigned as serial port pins. for these pins to function as serial port pins, they must have their corresponding data direction bits set or cleared in the associated tris register as follows: ? sdi configured as input ? sdo configured as output ? sck configured as output 17.1.1.3 master mode setup in master mode, the data is transmitted/received as soon as the sspbuf register is loaded with a byte value. if the master is only going to receive, sdo output could be disabled (programmed and used as an input). the sspsr register will continue to shift in the signal present on the sdi pin at the programmed clock rate. when initializing spi master mode operation, several options need to be specified. this is accomplished by programming the appropriate control bits in the sspcon and sspstat registers. these control bits allow the following to be specified: ? sck as clock output ? idle state of sck (ckp bit) ? data input sample phase (smp bit) ? output data on rising/falling edge of sck (cke bit) ? clock bit rate in master mode, the spi clock rate (bit rate) is user selectable to be one of the following: ?f osc /4 (or tcy) ?f osc /16 (or 4 ? tcy) ?f osc /64 (or 16 ? tcy) ? (timer2 output)/2 this allows a maximum data rate of 5 mbps (at f osc =20mhz). figure 17-3 shows the waveforms for master mode. the clock polarity is selected by appropriately program- ming the ckp bit of the sspcon register. when the cke bit is set, the sdo data is valid before there is a clock edge on sck. the sample time of the input data is shown based on the state of the smp bit and can occur at the middle or end of the data output time. the time when the sspbuf is loaded with the received data is shown. 17.1.1.4 sleep in master mode in master mode, all module clocks are halted and the transmission/reception will remain in their current state, paused, until the device wakes from sleep. after the device wakes up from sleep, the module will continue to transmit/receive data. note: the sspsr is not directly readable or writable and can only be accessed by addressing the sspbuf register.
pic16f/lf722a/723a ds41417a-page 158 ? 2010 microchip technology inc. figure 17-3: spi master mode waveform example 17-1: loading the sspbuf (sspsr) register sck (ckp = 0 sck (ckp = 1 sck (ckp = 0 sck (ckp = 1 4 clock modes input sample input sample sdi bit 7 bit 0 sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 7 bit 0 sdi sspif (smp = 1 ) (smp = 0 ) (smp = 1 ) cke = 1 ) cke = 0 ) cke = 1 ) cke = 0 ) (smp = 0 ) write to sspbuf sspsr to sspbuf sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 (cke = 0 ) (cke = 1 ) banksel sspstat ; loop btfss sspstat, bf ;has data been received(transmit complete)? goto loop ;no banksel sspbuf ; movf sspbuf, w ;wreg reg = contents of sspbuf movwf rxdata ;save in user ram, if data is meaningful movf txdata, w ;w reg = contents of txdata movwf sspbuf ;new data to xmit
? 2010 microchip technology inc. ds41417a-page 159 pic16f/lf722a/723a 17.1.2 slave mode for any spi device acting as a slave, the data is transmitted and received as external clock pulses appear on sck pin. this external clock must meet the minimum high and low times as specified in the electrical specifications. 17.1.2.1 slave mode operation the ssp consists of a transmit/receive shift register (sspsr) and a buffer register (sspbuf). the sspsr shifts the data in and out of the device, msb first. the sspbuf holds the data that was written to the sspsr until the received data is ready. the slave has no control as to when data will be clocked in or out of the device. all data that is to be transmitted, to a master or another slave, must be loaded into the sspbuf register before the first clock pulse is received. once eight bits of data have been received: ? received byte is moved to the sspbuf register ? bf bit of the sspstat register is set ? sspif bit of the pir1 register is set any write to the sspbuf register during transmission/ reception of data will be ignored and the write collision detect bit, wcol of the sspcon register, will be set. user software must clear the wcol bit so that it can be determined if the following write(s) to the sspbuf register completed successfully. the user?s firmware must read sspbuf, clearing the bf flag, or the sspov bit of the sspcon register will be set with the reception of the next byte and communication will be disabled. a spi module transmits and receives at the same time, occasionally causing dummy data to be transmitted/ received. it is up to the user to determine which data is to be used and what can be discarded. 17.1.2.2 enabling slave i/o to enable the serial port, the sspen bit of the sspcon register must be set. if a slave mode of operation is selected in the sspm bits of the sspcon register, the sdi, sdo and sck pins will be assigned as serial port pins. for these pins to function as serial port pins, they must have their corresponding data direction bits set or cleared in the associated tris register as follows: ? sdi configured as input ? sdo configured as output ? sck configured as input optionally, a fourth pin, slave select (ss ) may be used in slave mode. slave select may be configured to operate on one of the following pins via the sssel bit in the apfcon register. ?ra5/an4/ss ?ra0/an0/ss upon selection of a slave select pin, the appropriate bits must be set in the ansela and trisa registers. slave select must be set as an input by setting the corresponding bit in trisa, and digital i/o must be enabled on the ss pin by clearing the corresponding bit of the ansela register. 17.1.2.3 slave mode setup when initializing the ssp module to spi slave mode, compatibility must be ensured with the master device. this is done by programming the appropriate control bits of the sspcon and sspstat registers. these control bits allow the following to be specified: ? sck as clock input ? idle state of sck (ckp bit) ? data input sample phase (smp bit) ? output data on rising/falling edge of sck (cke bit) figure 17-4 and figure 17-5 show example waveforms of slave mode operation.
pic16f/lf722a/723a ds41417a-page 160 ? 2010 microchip technology inc. figure 17-4: spi mode waveform (slave mode with cke = 0 ) figure 17-5: spi mode waveform (slave mode with cke = 1 ) sck (ckp = 1 sck (ckp = 0 input sample sdi bit 7 bit 0 sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sspif interrupt (smp = 0 ) cke = 0 ) cke = 0 ) (smp = 0 ) write to sspbuf sspsr to sspbuf ss flag optional sck (ckp = 1 sck (ckp = 0 input sample sdi bit 7 bit 0 sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sspif interrupt (smp = 0 ) cke = 1 ) cke = 1 ) (smp = 0 ) write to sspbuf sspsr to sspbuf ss flag not optional
? 2010 microchip technology inc. ds41417a-page 161 pic16f/lf722a/723a 17.1.2.4 slave select operation the ss pin allows synchronous slave mode operation. the spi must be in slave mode with ss pin control enabled (sspm<3:0> = 0100 ). the associated tris bit for the ss pin must be set, making ss an input. in slave select mode, when: ?ss = 0 , the device operates as specified in section 17.1.2 ?slave mode? . ?ss = 1 , the spi module is held in reset and the sdo pin will be tri-stated. when the spi module resets, the bit counter is cleared to ? 0 ?. this can be done by either forcing the ss pin to a high level or clearing the sspen bit. figure 17-6 shows the timing waveform for such a synchronization event. 17.1.2.5 sleep in slave mode while in sleep mode, the slave can transmit/receive data. the spi transmit/receive shift register operates asynchronously to the device on the externally supplied clock source. this allows the device to be placed in sleep mode and data to be shifted into the spi trans- mit/receive shift register. when all 8 bits have been received, the ssp interrupt flag bit will be set and if enabled, will wake the device from sleep. figure 17-6: slave select synchro nization waveform note 1: when the spi is in slave mode with ss pin control enabled (sspm<3:0> = 0100 ), the spi module will reset if the ss pin is driven high. 2: if the spi is used in slave mode with cke set, the ss pin control must be enabled. note: sspsr must be reinitialized by writing to the sspbuf register before the data can be clocked out of the slave again. sck (ckp = 1 sck (ckp = 0 input sample sdi bit 7 sdo bit 7 bit 6 bit 7 sspif interrupt (smp = 0 ) cke = 0 ) cke = 0 ) (smp = 0 ) write to sspbuf sspsr to sspbuf ss flag bit 0 bit 7 bit 0 sspsr must be reinitialized by writing to the sspbuf register before the data can be clocked out of the slave again.
pic16f/lf722a/723a ds41417a-page 162 ? 2010 microchip technology inc. register 17-1: sspcon: sync serial po rt control register (spi mode) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 wcol : write collision detect bit 1 = the sspbuf register is written while it is still transmitting the previous word (must be cleared in software) 0 = no collision bit 6 sspov : receive overflow indicator bit 1 = a new byte is received while the sspbuf register is still holding the previous data. in case of overflow, the data in sspsr is lost. overflow can only occur in slave mode. the user must read the sspbuf, even if only transmitting data, to avoid setting overflow. in master mode, the over- flow bit is not set since each new reception (and transmission) is initiated by writing to the sspbuf register. 0 = no overflow bit 5 sspen : synchronous serial port enable bit 1 = enables serial port and configures sck, sdo and sdi as serial port pins (1) 0 = disables serial port and configures these pins as i/o port pins bit 4 ckp : clock polarity select bit 1 = idle state for clock is a high level 0 = idle state for clock is a low level bit 3-0 sspm<3:0> : synchronous serial port mode select bits 0000 = spi master mode, clock = f osc /4 0001 = spi master mode, clock = f osc /16 0010 = spi master mode, clock = f osc /64 0011 = spi master mode, clock = tmr2 output/2 0100 = spi slave mode, clock = sck pin. ss pin control enabled. 0101 = spi slave mode, clock = sck pin. ss pin control disabled. ss can be used as i/o pin. note 1: when enabled, these pins must be properly configured as input or output.
? 2010 microchip technology inc. ds41417a-page 163 pic16f/lf722a/723a register 17-2: sspstat: sync serial port status register (spi mode) r/w-0 r/w-0 r-0 r-0 r-0 r-0 r-0 r-0 smp cke d/a psr/w ua bf bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 smp : spi data input sample phase bit spi master mode: 1 = input data sampled at end of data output time 0 = input data sampled at middle of data output time spi slave mode: smp must be cleared when spi is used in slave mode bit 6 cke : spi clock edge select bit spi mode, ckp = 0 : 1 = data stable on rising edge of sck 0 = data stable on falling edge of sck spi mode, ckp = 1 : 1 = data stable on falling edge of sck 0 = data stable on rising edge of sck bit 5 d/a : data/address bit used in i 2 c mode only. bit 4 p: stop bit used in i 2 c mode only. bit 3 s: start bit used in i 2 c mode only. bit 2 r/w : read/write information bit used in i 2 c mode only. bit 1 ua: update address bit used in i 2 c mode only. bit 0 bf : buffer full status bit 1 = receive complete, sspbuf is full 0 = receive not complete, sspbuf is empty
pic16f/lf722a/723a ds41417a-page 164 ? 2010 microchip technology inc. table 17-1: summary of registers associated with spi operation name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets ansela ? ?ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 --11 1111 --11 1111 apfcon ? ? ? ? ? ? sssel ccp2sel ---- --00 ---- --00 intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pr2 timer2 period register 1111 1111 1111 1111 sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx uuuu uuuu sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 sspstat smp cke d/a p s r/w ua bf 0000 0000 0000 0000 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used by the ssp in spi mode.
? 2010 microchip technology inc. ds41417a-page 165 pic16f/lf722a/723a 17.2 i 2 c mode the ssp module, in i 2 c mode, implements all slave functions, except general call support. it provides interrupts on start and stop bits in hardware to facilitate firmware implementations of the master functions. the ssp module implements the i 2 c standard mode specifications: ?i 2 c slave mode (7-bit address) ?i 2 c slave mode (10-bit address) ? start and stop bit interrupts enabled to support firmware master mode ?address masking two pins are used for data transfer; the scl pin (clock line) and the sda pin (data line). the user must configure the two pin?s data direction bits as inputs in the appropriate tris register. upon enabling i 2 c mode, the i 2 c slew rate limiters in the i/o pads are controlled by the smp bit of sspstat register. the ssp module functions are enabled by setting the sspen bit of sspcon register. data is sampled on the rising edge and shifted out on the falling edge of the clock. this ensures that the sda signal is valid during the scl high time. the scl clock input must have minimum high and low times for proper operation. refer to section 23.0 ?electrical specifications? . figure 17-7: i 2 c? mode block diagram figure 17-8: typical i 2 c? connections the ssp module has six registers for i 2 c operation. they are: ? ssp control (sspcon) register ? ssp status (sspstat) register ? serial receive/transmit buffer (sspbuf) register ? ssp shift register (sspsr), not directly accessible ? ssp address (sspadd) register ? ssp address mask (sspmsk) register 17.2.1 hardware setup selection of i 2 c mode, with the sspen bit of the sspcon register set, forces the scl and sda pins to be open drain, provided these pins are programmed as inputs by setting the appropriate trisc bits. the ssp module will override the input state with the output data, when required, such as for acknowledge and slave-transmitter sequences. read write sspsr reg match detect sspadd reg start and stop bit detect sspbuf reg internal data bus addr match scl sda shift clock msb lsb sspmsk reg note: pull-up resistors must be provided externally to the scl and sda pins for proper operation of the i 2 c module. slave 1 master sda scl v dd v dd sda scl slave 2 sda scl (optional)
pic16f/lf722a/723a ds41417a-page 166 ? 2010 microchip technology inc. 17.2.2 start and stop conditions during times of no data transfer (idle time), both the clock line (scl) and the data line (sda) are pulled high through external pull-up resistors. the start and stop conditions determine the start and stop of data trans- mission. the start condition is defined as a high-to-low transition of the sda line while scl is high. the stop condition is defined as a low-to-high transition of the sda line while scl is high. figure 17-9 shows the start and stop conditions. a master device generates these conditions for starting and terminating data transfer. due to the definition of the start and stop conditions, when data is being trans- mitted, the sda line can only change state when the scl line is low. figure 17-9: start and stop conditions 17.2.3 acknowledge after the valid reception of an address or data byte, the hardware automatically will generate the acknowledge (ack ) pulse and load the sspbuf register with the received value currently in the sspsr register. there are certain conditions that will cause the ssp module not to generate this ack pulse. they include any or all of the following: ? the buffer full bit, bf of the sspstat register, was set before the transfer was received. ? the ssp overflow bit, sspov of the sspcon register, was set before the transfer was received. ? the ssp module is being operated in firmware master mode. in such a case, the sspsr register value is not loaded into the sspbuf, but bit sspif of the pir1 register is set. table 17-2 shows the results of when a data transfer byte is received, given the status of bits bf and sspov. flag bit bf is cleared by reading the sspbuf register, while bit sspov is cleared through software. table 17-2: data transfer received byte actions sda scl p stop condition s start condition change of data allowed change of data allowed status bits as data transfer is received sspsr ? sspbuf generate ack pulse set bit sspif (ssp interrupt occurs if enabled) bf sspov 00 yes yes yes 10 no no yes 11 no no yes 0 1 no no yes note 1: shaded cells show the conditions where the user software did not properly clear the overflow condition.
? 2010 microchip technology inc. ds41417a-page 167 pic16f/lf722a/723a 17.2.4 addressing once the ssp module has been enabled, it waits for a start condition to occur. following the start condition, the 8 bits are shifted into the sspsr register. all incoming bits are sampled with the rising edge of the clock line (scl). 17.2.4.1 7-bit addressing in 7-bit addressing mode (figure 17-10), the value of register sspsr<7:1> is compared to the value of reg- ister sspadd<7:1>. the address is compared on the falling edge of the eighth clock (scl) pulse. if the addresses match, and the bf and sspov bits are clear, the following events occur: ? the sspsr register value is loaded into the sspbuf register. ? the bf bit is set. ?an ack pulse is generated. ? ssp interrupt flag bit, sspif of the pir1 register, is set (interrupt is generated if enabled) on the falling edge of the ninth scl pulse. 17.2.4.2 10-bit addressing in 10-bit address mode, two address bytes need to be received by the slave (figure 17-11). the five most significant bits (msbs) of the first address byte specify if it is a 10-bit address. the r/w bit of the sspstat register must specify a write so the slave device will receive the second address byte. for a 10-bit address, the first byte would equal ? 1111 0 a9 a8 0 ?, where a9 and a8 are the two msbs of the address. the sequence of events for 10-bit address is as follows for reception: 1. load sspadd register with high byte of address. 2. receive first (high) byte of address (bits sspif, bf and ua of the sspstat register are set). 3. read the sspbuf register (clears bit bf). 4. clear the sspif flag bit. 5. update the sspadd register with second (low) byte of address (clears ua bit and releases the scl line). 6. receive low byte of address (bits sspif, bf and ua are set). 7. update the sspadd register with the high byte of address. if match releases scl line, this will clear bit ua. 8. read the sspbuf register (clears bit bf). 9. clear flag bit sspif. if data is requested by the master, once the slave has been addressed: 1. receive repeated start condition. 2. receive repeat of high byte address with r/w = 1 , indicating a read. 3. bf bit is set and the ckp bit is cleared, stopping scl and indicating a read request. 4. sspbuf is written, setting bf, with the data to send to the master device. 5. ckp is set in software, releasing the scl line. 17.2.4.3 address masking the address masking register (sspmsk) is only accessible while the sspm bits of the sspcon register are set to ? 1001 ?. in this register, the user can select which bits of a received address the hardware will compare when determining an address match. any bit that is set to a zero in the sspmsk register, the corresponding bit in the received address byte and sspadd register are ignored when determining an address match. by default, the register is set to all ones, requiring a complete match of a 7-bit address or the lower eight bits of a 10-bit address.
pic16f/lf722a/723a ds41417a-page 168 ? 2010 microchip technology inc. 17.2.5 reception when the r/w bit of the received address byte is clear, the master will write data to the slave. if an address match occurs, the received address is loaded into the sspbuf register. an address byte overflow will occur if that loaded address is not read from the sspbuf before the next complete byte is received. an ssp interrupt is generated for each data transfer byte. the bf, r/w and d/a bits of the sspstat register are used to determine the status of the last received byte. figure 17-10: i 2 c? waveforms for reception (7-bit address) p 9 8 7 6 5 d0 d1 d2 d3 d4 d5 d6 d7 s a7 a6 a5 a4 a3 a2 a1 sda scl 1 2 34 56 78 9123 4 567 89 12 34 bus master sends stop condition bit sspov is set because the sspbuf register is still full. cleared in software sspbuf register is read ack receiving data receiving data d0 d1 d2 d3 d4 d5 d6 d7 ack r/w = 0 receiving address sspif bf sspov ack ack is not sent.
? 2010 microchip technology inc. ds41417a-page 169 pic16f/lf722a/723a figure 17-11: i 2 c? slave mode timing (reception, 10-bit address) sspif bf receive data byte r/w receive first byte of address cleared in software cleared in software receive second byte of address cleared by hardware when sspadd is updated with low byte of address ua clock is held low until update of sspadd has taken place ua is set indicating that the sspadd needs to be updated ua is set indicating that sspadd needs to be updated cleared by hardware when sspadd is updated with high byte of address sspbuf is written with contents of sspsr dummy read of sspbuf to clear bf flag ckp receive data byte bus master sends stop condition ack cleared in software cleared in software sspov sspov is set because sspbuf is still full. ack is not sent. clock is held low until update of sspadd has taken place sda scl s 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 7 8 9 p 1 1 1 1 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 d7 d6 d5 d4 d3 d1 d0 ack ack d2 6 ack 1 2 3 4 5 7 8 9 d7 d6 d5 d4 d3 d1 d0 d2 6 ack 0
pic16f/lf722a/723a ds41417a-page 170 ? 2010 microchip technology inc. 17.2.6 transmission when the r/w bit of the received address byte is set and an address match occurs, the r/w bit of the sspstat register is set and the slave will respond to the master by reading out data. after the address match, an ack pulse is generated by the slave hardware and the scl pin is held low (clock is automatically stretched) until the slave is ready to respond. see section 17.2.7 ?clock stretching? . the data the slave will transmit must be loaded into the sspbuf register, which sets the bf bit. the scl line is released by setting the ckp bit of the sspcon register. an ssp interrupt is generated for each transferred data byte. the sspif flag bit of the pir1 register initiates an ssp interrupt, and must be cleared by software before the next byte is transmitted. the bf bit of the sspstat register is cleared on the falling edge of the 8th received clock pulse. the sspif flag bit is set on the falling edge of the ninth clock pulse. following the 8th falling clock edge, control of the sda line is released back to the master so that the master can acknowledge or not acknowledge the response. if the master sends a not acknowledge, the slave?s transmission is complete and the slave must monitor for the next start condition. if the master acknowledges, control of the bus is returned to the slave to transmit another byte of data. just as with the previous byte, the clock is stretched by the slave, data must be loaded into the sspbuf and ckp must be set to release the clock line (scl). figure 17-12: i 2 c waveforms for transmission (7-bit address) sda scl sspif bf ckp a7 a6 a5 a4 a3 a2 a1 ack d7 d6 d5 d4 d3 d2 d1 d0 ack transmitting data r/w receiving address 123456789 123456789 p cleared in software set bit after writing to sspbuf s data in sampled scl held low while cpu responds to sspif (the sspbuf must be written to before the ckp bit can be set) dummy read of sspbuf to clear bf flag sspbuf is written in software from ssp interrupt service routine
? 2010 microchip technology inc. ds41417a-page 171 pic16f/lf722a/723a figure 17-13: i 2 c slave mode timing (transmission 10-bit address) sda scl sspif bf s 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 7 8 9 p 1 1 1 1 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 1 1 1 1 0 a8 r/w = 1 ack ack r/w = 0 ack receive first byte of address cleared in software bus master sends stop condition a9 6 receive second byte of address cleared by hardware when sspadd is updated with low byte of address. ua clock is held low until update of sspadd has taken place ua is set indicating that the sspadd needs to be updated ua is set indicating that sspadd needs to be updated cleared by hardware when sspadd is updated with high byte of address. sspbuf is written with contents of sspsr dummy read of sspbuf to clear bf flag receive first byte of address 1 2 3 4 5 7 8 9 d7 d6 d5 d4 d3 d1 ack d2 6 transmitting data byte d0 dummy read of sspbuf to clear bf flag sr cleared in software write of sspbuf cleared in software completion of clears bf flag ckp ckp is set in software, initiates transmission ckp is automatically cleared in hardware holding scl low clock is held low until update of sspadd has taken place data transmission clock is held low until ckp is set to ? 1 ? bus master sends restarts condition dummy read of sspbuf to clear bf flag
pic16f/lf722a/723a ds41417a-page 172 ? 2010 microchip technology inc. 17.2.7 clock stretching during any scl low phase, any device on the i 2 c bus may hold the scl line low and delay, or pause, the transmission of data. this ?stretching? of a transmission allows devices to slow down communication on the bus. the scl line must be constantly sampled by the master to ensure that all devices on the bus have released scl for more data. stretching usually occurs after an ack bit of a transmission, delaying the first bit of the next byte. the ssp module hardware automatically stretches for two conditions: ? after a 10-bit address byte is received (update sspadd register) ? anytime the ckp bit of the sspcon register is cleared by hardware the module will hold scl low until the ckp bit is set. this allows the user slave software to update sspbuf with data that may not be readily available. in 10-bit addressing modes, the sspadd register must be updated after receiving the first and second address bytes. the ssp module will hold the scl line low until the sspadd has a byte written to it. the ua bit of the sspstat register will be set, along with sspif, indicating an address update is needed. 17.2.8 firmware master mode master mode of operation is supported in firmware using interrupt generation on the detection of the start and stop conditions. the stop (p) and start (s) bits of the sspstat register are cleared from a reset or when the ssp module is disabled (sspen cleared). the stop (p) and start (s) bits will toggle based on the start and stop conditions. control of the i 2 c bus may be taken when the p bit is set or the bus is idle and both the s and p bits are clear. in firmware master mode, the scl and sda lines are manipulated by setting/clearing the corresponding tris bit(s). the output level is always low, irrespective of the value(s) in the corresponding port register bit(s). when transmitting a ? 1 ?, the tris bit must be set (input) and a ? 0 ?, the tris bit must be clear (output). the following events will cause the ssp interrupt flag bit, sspif, to be set (ssp interrupt will occur if enabled): ? start condition ? stop condition ? data transfer byte transmitted/received firmware master mode of operation can be done with either the slave mode idle (sspm<3:0> = 1011 ), or with either of the slave modes in which interrupts are enabled. when both master and slave functionality is enabled, the software needs to differentiate the source(s) of the interrupt. refer to application note an554, ? software implementation of i 2 c? bus master ? (ds00554) for more information. 17.2.9 multi-master mode in multi-master mode, the interrupt generation on the detection of the start and stop conditions allow the determination of when the bus is free. the stop (p) and start (s) bits are cleared from a reset or when the ssp module is disabled. the stop (p) and start (s) bits will toggle based on the start and stop conditions. control of the i 2 c bus may be taken when the p bit of the sspstat register is set or when the bus is idle, and both the s and p bits are clear. when the bus is busy, enabling the ssp interrupt will generate the interrupt when the stop condition occurs. in multi-master operation, the sda line must be monitored to see if the signal level is the expected output level. this check only needs to be done when a high level is output. if a high level is expected and a low level is present, the device needs to release the sda and scl lines (set tris bits). there are two stages where this arbitration of the bus can be lost. they are the address transfer and data transfer stages. when the slave logic is enabled, the slave continues to receive. if arbitration was lost during the address transfer stage, communication to the device may be in progress. if addressed, an ack pulse will be generated. if arbitration was lost during the data transfer stage, the device will need to re-transfer the data at a later time. refer to application note an578, ? use of the ssp module in the i 2 c? multi-master environment ? (ds00578) for more information.
? 2010 microchip technology inc. ds41417a-page 173 pic16f/lf722a/723a 17.2.10 clock synchronization when the ckp bit is cleared, the scl output is held low once it is sampled low. therefore, the ckp bit will not stretch the scl line until an external i 2 c master device has already asserted the scl line low. the scl output will remain low until the ckp bit is set and all other devices on the i 2 c bus have released scl. this ensures that a write to the ckp bit will not violate the minimum high time requirement for scl (figure 17-14). 17.2.11 sleep operation while in sleep mode, the i 2 c module can receive addresses of data, and when an address match or complete byte transfer occurs, wake the processor from sleep (if ssp interrupt is enabled). figure 17-14: clock synchronization timing sda scl dx-1 dx wr q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 sspcon ckp master device deasserts clock master device asserts clock
pic16f/lf722a/723a ds41417a-page 174 ? 2010 microchip technology inc. register 17-3: sspcon: synchronous se rial port control register (i 2 c mode) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 wcol : write collision detect bit 1 = the sspbuf register is written while it is still transmitting the previous word (must be cleared in software) 0 = no collision bit 6 sspov : receive overflow indicator bit 1 = a byte is received while the sspbuf register is still holding the previous byte. sspov is a ?don?t care? in transmit mode. sspov must be cleared in software in either mode. 0 = no overflow bit 5 sspen : synchronous serial port enable bit 1 = enables the serial port and configures the sda and scl pins as serial port pins (2) 0 = disables serial port and configures these pins as i/o port pins bit 4 ckp : clock polarity select bit 1 = release control of scl 0 = holds clock low (clock stretch). (used to ensure data setup time.) bit 3-0 sspm<3:0> : synchronous serial port mode select bits 0110 = i 2 c slave mode, 7-bit address 0111 = i 2 c slave mode, 10-bit address 1000 = reserved 1001 = load sspmsk register at sspadd sfr address (1) 1010 = reserved 1011 = i 2 c firmware controlled master mode (slave idle) 1100 = reserved 1101 = reserved 1110 = i 2 c slave mode, 7-bit address with start and stop bit interrupts enabled 1111 = i 2 c slave mode, 10-bit address with start and stop bit interrupts enabled note 1: when this mode is selected, any reads or writes to the sspadd sfr address accesses the sspmsk register. 2: when enabled, these pins must be properly configured as input or output using the associated tris bit.
? 2010 microchip technology inc. ds41417a-page 175 pic16f/lf722a/723a register 17-4: sspstat: synchronous serial port status register (i 2 c mode) r/w-0 r/w-0 r-0 r-0 r-0 r-0 r-0 r-0 smp cke d/a psr/w ua bf bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 smp : spi data input sample phase bit 1 = slew rate control (limiting) disabled. operating in i 2 c standard mode (100 khz and 1 mhz). 0 = slew rate control (limiting) enabled. operating in i 2 c fast mode (400 khz). bit 6 cke : spi clock edge select bit this bit must be maintained clear. used in spi mode only. bit 5 d/a : data/address bit (i 2 c mode only) 1 = indicates that the last byte received or transmitted was data 0 = indicates that the last byte received or transmitted was address bit 4 p : stop bit this bit is cleared when the ssp module is disabled, or when the start bit is detected last. 1 = indicates that a stop bit has been detected last (this bit is ? 0 ? on reset) 0 = stop bit was not detected last bit 3 s : start bit this bit is cleared when the ssp module is disabled, or when the stop bit is detected last. 1 = indicates that a start bit has been detected last (this bit is ? 0 ? on reset) 0 = start bit was not detected last bit 2 r/w : read/write bit information this bit holds the r/w bit information following the last address match. this bit is only valid from the address match to the next start bit, stop bit or ack bit. 1 = read 0 = write bit 1 ua : update address bit (10-bit i 2 c mode only) 1 = indicates that the user needs to update the address in the sspadd register 0 = address does not need to be updated bit 0 bf : buffer full status bit receive: 1 = receive complete, sspbuf is full 0 = receive not complete, sspbuf is empty transmit: 1 = transmit in progress, sspbuf is full 0 = transmit complete, sspbuf is empty
pic16f/lf722a/723a ds41417a-page 176 ? 2010 microchip technology inc. table 17-7: registers associated with i 2 c operation register 17-5: sspmsk: ssp mask register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 msk7 msk6 msk5 msk4 msk3 msk2 msk1 msk0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-1 msk<7:1>: mask bits 1 = the received address bit n is compared to sspadd to detect i 2 c address match 0 = the received address bit n is not used to detect i 2 c address match bit 0 msk<0>: mask bit for i 2 c slave mode, 10-bit address i 2 c slave mode, 10-bit address (sspm<3:0> = 0111 ): 1 = the received address bit ? 0 ? is compared to sspadd<0> to detect i 2 c address match 0 = the received address bit ? 0 ? is not used to detect i 2 c address match all other ssp modes: this bit has no effect. register 17-6: sspadd: ssp i 2 c address register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 add7 add6 add5 add4 add3 add2 add1 add0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 add<7:0>: address bits received address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000u pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx uuuu uuuu sspadd synchronous serial port (i 2 c mode) address register 0000 0000 0000 0000 sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 sspmsk (2) synchronous serial port (i 2 c mode) address mask register 1111 1111 1111 1111 sspstat smp (1) cke (1) d/a psr/w ua bf 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by ssp module in i 2 c mode. note 1: maintain these bits clear in i 2 c mode. 2: accessible only when sspm<3:0> = 1001 .
? 2010 microchip technology inc. ds41417a-page 177 pic16f/lf722a/723a 18.0 program memory read the flash program memory is readable during normal operation over the full v dd range of the device. to read data from program memory, five special function registers (sfrs) are used: ?pmcon1 ?pmdatl ?pmdath ? pmadrl ? pmadrh the value written to the pmadrh:pmadrl register pair determines which program memory location is read. the read operation will be initiated by setting the rd bit of the pmcon1 register. the program memory flash controller takes two instructions to complete the read. as a consequence, after the rd bit has been set, the next two instructions will be ignored. to avoid conflict with program execution, it is recommended that the two instructions following the setting of the rd bit are nop . when the read completes, the result is placed in the pmdatlh:pmdatl register pair. refer to example 18-1 for sample code. example 18-1: program memory read note: code-protect does not effect the cpu from performing a read operation on the program memory. for more information, refer to section 8.2 ?code protection? banksel pmadrl ; movf ms_prog_addr, w; movwf pmadrh ;ms byte of program address to read movf ls_prog_addr, w; movwf pmadrl ;ls byte of program address to read banksel pmcon1 ; bsf pmcon1, rd;initiate read nop nop ;any instructions here are ignored as program ;memory is read in second cycle after bsf banksel pmdatl ; movf pmdatl, w;w = ls byte of program memory read movwf lowpmbyte; movf pmdath, w;w = ms byte of program memory read movwf highpmbyte; required sequence
pic16f/lf722a/723a ds41417a-page 178 ? 2010 microchip technology inc. register 18-1: pmcon1: progra m memory control 1 register r-1 u-0 u-0 u-0 u-0 u-0 u-0 r/s-0 reserved ? ?l ? ? ? ?rd bit 7 bit 0 legend: s = setable bit, cleared in hardware r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 reserved: read as ? 1 ?. maintain this bit set. bit 6-1 unimplemented: read as ? 0 ? bit 0 rd: read control bit 1 = initiates an program memory read (the rd is cleared in hardware; the rd bit can only be set (not cleared) in software). 0 = does not initiate a program memory read register 18-2: pmdath: program memory data high register u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x ? ? pmd13 pmd12 pmd11 pmd10 pmd9 pmd8 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5-0 pmd<13:8>: the value of the program memory word pointed to by pmadrh and pmadrl after a program memory read command. register 18-3: pmdatl: program memory data low register r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x pmd7 pmd6 pmd5 pmd4 pmd3 pmd2 pmd1 pmd0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 pmd<7:0>: the value of the program memory word pointed to by pmadrh and pmadrl after a program memory read command.
? 2010 microchip technology inc. ds41417a-page 179 pic16f/lf722a/723a table 18-1: summary of registers as sociated with program memory read register 18-4: pmadrh: program memory address high register u-0 u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x ? ? ? pma12 pma11 pma10 pma9 pma8 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-5 unimplemented: read as ? 0 ? bit 4-0 pma<12:8>: program memory read address bits register 18-5: pmadrl: program memory address low register r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x pma7 pma6 pma5 pma4 pma3 pma2 pma1 pma0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 pma<7:0>: program memory read address bits name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets pmcon1 reserved ? ? ? ? ? ?rd 1--- ---0 1--- ---0 pmadrh ? ? ? program memory read address register high byte ---x xxxx ---x xxxx pmadrl program memory read address register low byte xxxx xxxx xxxx xxxx pmdath ? ? program memory read data register high byte --xx xxxx --xx xxxx pmdatl program memory read data register low byte xxxx xxxx xxxx xxxx legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used by the program memory read.
pic16f/lf722a/723a ds41417a-page 180 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 181 pic16f/lf722a/723a 19.0 power-down mode (sleep) the power-down mode is entered by executing a sleep instruction. if the watchdog timer is enabled: ? wdt will be cleared but keeps running. ?pd bit of the status register is cleared. ?to bit of the status register is set. ? oscillator driver is turned off. ? timer1 oscillator is unaffected ? i/o ports maintain the status they had before sleep was executed (driving high, low or high- impedance). for lowest current consumption in this mode, all i/o pins should be either at v dd or v ss , with no external circuitry drawing current from the i/o pin. i/o pins that are high-impedance inputs should be pulled high or low externally to avoid switching currents caused by float- ing inputs. the t0cki input should also be at v dd or v ss for lowest current consumption. the contribution from on-chip pull-ups on portb should be considered. the mclr pin must be at a logic high level when external mclr is enabled. 19.1 wake-up from sleep the device can wake-up from sleep through one of the following events: 1. external reset input on mclr pin. 2. watchdog timer wake-up (if wdt was enabled). 3. interrupt from rb0/int pin, portb change or a peripheral interrupt. the first event will cause a device reset. the two latter events are considered a continuation of program execution. the to and pd bits in the status register can be used to determine the cause of device reset. the pd bit, which is set on power-up, is cleared when sleep is invoked. to bit is cleared if wdt wake-up occurred. the following peripheral interrupts can wake the device from sleep: 1. tmr1 interrupt. timer1 must be operating as an asynchronous counter. 2. usart receive interrupt (synchronous slave mode only) 3. a/d conversion (when a/d clock source is rc) 4. interrupt-on-change 5. external interrupt from int pin 6. capture event on ccp1 or ccp2 7. ssp interrupt in spi or i 2 c slave mode other peripherals cannot generate interrupts since during sleep, no on-chip clocks are present. when the sleep instruction is being executed, the next instruction (pc + 1) is prefetched. for the device to wake-up through an interrupt event, the corresponding interrupt enable bit must be set (enabled). wake-up is regardless of the state of the gie bit. if the gie bit is clear (disabled), the device continues execution at the instruction after the sleep instruction. if the gie bit is set (enabled), the device executes the instruction after the sleep instruction, then branches to the interrupt address (0004h). in cases where the execution of the instruction following sleep is not desirable, the user should have a nop after the sleep instruction. the wdt is cleared when the device wakes up from sleep, regardless of the source of wake-up. note: a reset generated by a wdt time-out does not drive mclr pin low. note: if the global interrupts are disabled (gie is cleared), but any interrupt source has both its interrupt enable bit and the correspond- ing interrupt flag bits set, the device will immediately wake-up from sleep. the sleep instruction is completely executed.
pic16f/lf722a/723a ds41417a-page 182 ? 2010 microchip technology inc. 19.2 wake-up using interrupts when global interrupts are disabled (gie cleared) and any interrupt source has both its interrupt enable bit and interrupt flag bit set, one of the following will occur: ? if the interrupt occurs before the execution of a sleep instruction, the sleep instruction will complete as a nop . therefore, the wdt and wdt prescaler and postscaler (if enabled) will not be cleared, the to bit will not be set and the pd bit will not be cleared. ? if the interrupt occurs during or after the execution of a sleep instruction, the device will immediately wake-up from sleep. the sleep instruction will be completely executed before the wake-up. therefore, the wdt and wdt prescaler and postscaler (if enabled) will be cleared, the to bit will be set and the pd bit will be cleared. even if the flag bits were checked before executing a sleep instruction, it may be possible for flag bits to become set before the sleep instruction completes. to determine whether a sleep instruction executed, test the pd bit. if the pd bit is set, the sleep instruction was executed as a nop . to ensure that the wdt is cleared, a clrwdt instruction should be executed before a sleep instruction. figure 19-1: wake-up from sleep through interrupt table 19-1: summary of registers associated with power-down mode q1 q2 q3 q4 q1 q2 q3 q4 q1 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 (1) clkout (4) int pin intf flag (intcon reg.) gie bit (intcon reg.) instruction flow pc instruction fetched instruction executed pc pc + 1 pc + 2 inst(pc) = sleep inst(pc - 1) inst(pc + 1) sleep processor in sleep interrupt latency (3) inst(pc + 2) inst(pc + 1) inst(0004h) inst(0005h) inst(0004h) dummy cycle pc + 2 0004h 0005h dummy cycle t ost (2) pc + 2 note 1: xt, hs or lp oscillator mode assumed. 2: t ost = 1024 t osc (drawing not to scale). this delay does not apply to ec and rc oscillator modes. 3: gie = 1 assumed. in this case after wake-up, the processor jumps to 0004h. if gie = 0 , execution will continue in-line. 4: clkout is not available in xt, hs, lp or ec oscillator modes, but shown here for timing reference. name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets iocb iocb7 iocb6 iocb5 iocb4 iocb3 iocb2 iocb1 iocb0 0000 0000 0000 0000 intcon gie peie t0ie inte rbie t0if intf rbif 0000 0000 0000 0000 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pie2 ? ? ? ? ? ? ? ccp2ie ---- ---0 ---- ---0 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pir2 ? ? ? ? ? ? ? ccp2if ---- ---0 ---- ---0 legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used in power-down mode.
? 2010 microchip technology inc. ds41417a-page 183 pic16f/lf722a/723a 20.0 in-circuit serial programming? (icsp?) icsp? programming allows customers to manufacture circuit boards with unprogrammed devices. programming can be done after the assembly process allowing the device to be programmed with the most recent firmware or a custom firmware. five pins are needed for icsp? programming: ? icspclk ? icspdat ?mclr /v pp ?v dd ?v ss the device is placed into program/verify mode by holding the icspclk and icspdat pins low then raising the voltage on mclr /v pp from 0v to v pp . in program/verify mode the program memory, user ids and the configuration words are programmed through serial communications. the icspdat pin is a bidirectional i/o used for transferring the serial data and the iscpclk pin is the clock input. for more information on icsp? refer to the ? pic16f72x/pic16lf72x programming specification? (ds41332). figure 20-1: typical connect ion for icsp? programming note: the icd 2 produces a v pp voltage greater than the maximum v pp specification of the pic16f/lf722a/723a. when using this programmer, an external circuit, such as the ac164112 mplab icd 2 v pp voltage limiter, is required to keep the v pp voltage within the device specifications. v dd v pp gnd external device to be data clock v dd mclr /v pp v ss icspdat icspclk * * * to normal connections * isolation devices (as required). 10k programming signals programmed v dd
pic16f/lf722a/723a ds41417a-page 184 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 185 pic16f/lf722a/723a 21.0 instruction set summary the pic16f/lf722a/723a instruction set is highly orthogonal and is comprised of three basic categories: ? byte-oriented operations ? bit-oriented operations ? literal and control operations each pic16 instruction is a 14-bit word divided into an opcode, which specifies the instruction type and one or more operands, which further specify the operation of the instruction. the formats for each of the categories is presented in figure 21-1, while the various opcode fields are summarized in table 21-1. table 21-2 lists the instructions recognized by the mpasm tm assembler. for byte-oriented instructions, ?f? represents a file register designator and ?d? represents a destination designator. the file register designator specifies which file register is to be used by the instruction. the destination designator specifies where the result of the operation is to be placed. if ?d? is zero, the result is placed in the w register. if ?d? is one, the result is placed in the file register specified in the instruction. for bit-oriented instructions, ?b? represents a bit field designator, which selects the bit affected by the operation, while ?f? represents the address of the file in which the bit is located. for literal and control operations, ?k? represents an 8-bit or 11-bit constant, or literal value. one instruction cycle consists of four oscillator periods; for an oscillator frequency of 4 mhz, this gives a nominal instruction execution time of 1 ? s. all instructions are executed within a single instruction cycle, unless a conditional test is true, or the program counter is changed as a result of an instruction. when this occurs, the execution takes two instruction cycles, with the second cycle executed as a nop . all instruction examples use the format ? 0xhh ? to represent a hexadecimal number, where ? h ? signifies a hexadecimal digit. 21.1 read-modify-write operations any instruction that specifies a file register as part of the instruction performs a read-modify-write (r-m-w) operation. the register is read, the data is modified, and the result is stored according to either the instruc- tion, or the destination designator ?d?. a read operation is performed on a register even if the instruction writes to that register. for example, a clrf portb instruction will read portb, clear all the data bits, then write the result back to portb. this example would have the unin- tended consequence of clearing the condition that set the rbif flag. table 21-1: opcode field descriptions figure 21-1: general format for instructions field description f register file address (0x00 to 0x7f) w working register (accumulator) b bit address within an 8-bit file register k literal field, constant data or label x don?t care location (= 0 or 1 ). the assembler will generate code with x = 0 . it is the recommended form of use for compatibility with all microchip software tools. d destination select; d = 0 : store result in w , d = 1 : store result in file register f. default is d = 1. pc program counter to time-out bit c carry bit dc digit carry bit z zero bit pd power-down bit byte-oriented file register operations 13 8 7 6 0 d = 0 for destination w opcode d f (file #) d = 1 for destination f f = 7-bit file register address bit-oriented file register operations 13 10 9 7 6 0 opcode b (bit #) f (file #) b = 3-bit bit address f = 7-bit file register address literal and control operations 13 8 7 0 opcode k (literal) k = 8-bit immediate value 13 11 10 0 opcode k (literal) k = 11-bit immediate value general call and goto instructions only
pic16f/lf722a/723a ds41417a-page 186 ? 2010 microchip technology inc. table 21-2: pic16f/lf722a/723a instruction set mnemonic, operands description cycles 14-bit opcode status affected notes msb lsb byte-oriented file register operations addwf andwf clrf clrw comf decf decfsz incf incfsz iorwf movf movwf nop rlf rrf subwf swapf xorwf f, d f, d f ? f, d f, d f, d f, d f, d f, d f, d f ? f, d f, d f, d f, d f, d add w and f and w with f clear f clear w complement f decrement f decrement f, skip if 0 increment f increment f, skip if 0 inclusive or w with f move f move w to f no operation rotate left f through carry rotate right f through carry subtract w from f swap nibbles in f exclusive or w with f 1 1 1 1 1 1 1 (2) 1 1 (2) 1 1 1 1 1 1 1 1 1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0111 0101 0001 0001 1001 0011 1011 1010 1111 0100 1000 0000 0000 1101 1100 0010 1110 0110 dfff dfff lfff 0xxx dfff dfff dfff dfff dfff dfff dfff lfff 0xx0 dfff dfff dfff dfff dfff ffff ffff ffff xxxx ffff ffff ffff ffff ffff ffff ffff ffff 0000 ffff ffff ffff ffff ffff c, dc, z z z z z z z z z c c c, dc, z z 1, 2 1, 2 2 1, 2 1, 2 1, 2, 3 1, 2 1, 2, 3 1, 2 1, 2 1, 2 1, 2 1, 2 1, 2 1, 2 bit-oriented file register operations bcf bsf btfsc btfss f, b f, b f, b f, b bit clear f bit set f bit test f, skip if clear bit test f, skip if set 1 1 1 (2) 1 (2) 01 01 01 01 00bb 01bb 10bb 11bb bfff bfff bfff bfff ffff ffff ffff ffff 1, 2 1, 2 3 3 literal and control operations addlw andlw call clrwdt goto iorlw movlw retfie retlw return sleep sublw xorlw k k k ? k k k ? k ? ? k k add literal and w and literal with w call subroutine clear watchdog timer go to address inclusive or literal with w move literal to w return from interrupt return with literal in w return from subroutine go into standby mode subtract w from literal exclusive or literal with w 1 1 2 1 2 1 1 2 2 2 1 1 1 11 11 10 00 10 11 11 00 11 00 00 11 11 111x 1001 0kkk 0000 1kkk 1000 00xx 0000 01xx 0000 0000 110x 1010 kkkk kkkk kkkk 0110 kkkk kkkk kkkk 0000 kkkk 0000 0110 kkkk kkkk kkkk kkkk kkkk 0100 kkkk kkkk kkkk 1001 kkkk 1000 0011 kkkk kkkk c, dc, z z to , pd z to , pd c, dc, z z note 1: when an i/o register is modified as a function of itself (e.g., movf porta, 1 ), the value used will be that value present on the pins themselves. for example, if the data latch is ? 1 ? for a pin configured as input and is driven low by an external device, the data will be written back with a ? 0 ?. 2: if this instruction is executed on the tm r0 register (and where applicable, d = 1 ), the prescaler will be cleared if assigned to the timer0 module. 3: if the program counter (pc) is modified, or a conditional test is true, the instruction requires two cycles. the second cycle is executed as a nop .
? 2010 microchip technology inc. ds41417a-page 187 pic16f/lf722a/723a 21.2 instruction descriptions addlw add literal and w syntax: [ label ] addlw k operands: 0 ? k ? 255 operation: (w) + k ? (w) status affected: c, dc, z description: the contents of the w register are added to the eight-bit literal ?k? and the result is placed in the w register. addwf add w and f syntax: [ label ] addwf f,d operands: 0 ? f ? 127 d ??? 0 , 1 ? operation: (w) + (f) ? (destination) status affected: c, dc, z description: add the contents of the w register with register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?. andlw and literal with w syntax: [ label ] andlw k operands: 0 ? k ? 255 operation: (w) .and. (k) ? (w) status affected: z description: the contents of w register are and?ed with the eight-bit literal ?k?. the result is placed in the w register. andwf and w with f syntax: [ label ] andwf f,d operands: 0 ? f ? 127 d ??? 0 , 1 ? operation: (w) .and. (f) ? (destination) status affected: z description: and the w register with register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?. bcf bit clear f syntax: [ label ] bcf f,b operands: 0 ? f ? 127 0 ? b ? 7 operation: 0 ? (f) status affected: none description: bit ?b? in register ?f? is cleared. bsf bit set f syntax: [ label ] bsf f,b operands: 0 ? f ? 127 0 ? b ? 7 operation: 1 ? (f) status affected: none description: bit ?b? in register ?f? is set. btfsc bit test f, skip if clear syntax: [ label ] btfsc f,b operands: 0 ? f ? 127 0 ? b ? 7 operation: skip if (f) = 0 status affected: none description: if bit ?b? in register ?f? is ? 1 ?, the next instruction is executed. if bit ?b?, in register ?f?, is ? 0 ?, the next instruction is discarded, and a nop is executed instead, making this a 2-cycle instruction.
pic16f/lf722a/723a ds41417a-page 188 ? 2010 microchip technology inc. btfss bit test f, skip if set syntax: [ label ] btfss f,b operands: 0 ? f ? 127 0 ? b < 7 operation: skip if (f) = 1 status affected: none description: if bit ?b? in register ?f? is ? 0 ?, the next instruction is executed. if bit ?b? is ? 1 ?, then the next instruction is discarded and a nop is executed instead, making this a 2-cycle instruction. call call subroutine syntax: [ label ] call k operands: 0 ? k ? 2047 operation: (pc)+ 1 ? tos, k ? pc<10:0>, (pclath<4:3>) ? pc<12:11> status affected: none description: call subroutine. first, return address (pc + 1) is pushed onto the stack. the eleven-bit immediate address is loaded into pc bits <10:0>. the upper bits of the pc are loaded from pclath. call is a two-cycle instruction. clrf clear f syntax: [ label ] clrf f operands: 0 ? f ? 127 operation: 00h ? (f) 1 ? z status affected: z description: the contents of register ?f? are cleared and the z bit is set. clrw clear w syntax: [ label ] clrw operands: none operation: 00h ? (w) 1 ? z status affected: z description: w register is cleared. zero bit (z) is set. clrwdt clear watchdog timer syntax: [ label ] clrwdt operands: none operation: 00h ? wdt 0 ? wdt prescaler, 1 ? to 1 ? pd status affected: to , pd description: clrwdt instruction resets the watchdog timer. it also resets the prescaler of the wdt. status bits to and pd are set. comf complement f syntax: [ label ] comf f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: (f ) ? (destination) status affected: z description: the contents of register ?f? are complemented. if ?d? is ? 0 ?, the result is stored in w. if ?d? is ? 1 ?, the result is stored back in register ?f?. decf decrement f syntax: [ label ] decf f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: (f) - 1 ? (destination) status affected: z description: decrement register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?.
? 2010 microchip technology inc. ds41417a-page 189 pic16f/lf722a/723a decfsz decrement f, skip if 0 syntax: [ label ] decfsz f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: (f) - 1 ? (destination); skip if result = 0 status affected: none description: the contents of register ?f? are decremented. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. if the result is ? 1 ?, the next instruction is executed. if the result is ? 0 ?, then a nop is executed instead, making it a 2-cycle instruction. goto unconditional branch syntax: [ label ] goto k operands: 0 ? k ? 2047 operation: k ? pc<10:0> pclath<4:3> ? pc<12:11> status affected: none description: goto is an unconditional branch. the eleven-bit immediate value is loaded into pc bits <10:0>. the upper bits of pc are loaded from pclath<4:3>. goto is a two-cycle instruction. incf increment f syntax: [ label ] incf f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: (f) + 1 ? (destination) status affected: z description: the contents of register ?f? are incremented. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. incfsz increment f, skip if 0 syntax: [ label ] incfsz f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: (f) + 1 ? (destination), skip if result = 0 status affected: none description: the contents of register ?f? are incremented. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. if the result is ? 1 ?, the next instruction is executed. if the result is ? 0 ?, a nop is executed instead, making it a 2-cycle instruction. iorlw inclusive or literal with w syntax: [ label ] iorlw k operands: 0 ? k ? 255 operation: (w) .or. k ? (w) status affected: z description: the contents of the w register are or?ed with the eight-bit literal ?k?. the result is placed in the w register. iorwf inclusive or w with f syntax: [ label ] iorwf f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: (w) .or. (f) ? (destination) status affected: z description: inclusive or the w register with register ?f?. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?.
pic16f/lf722a/723a ds41417a-page 190 ? 2010 microchip technology inc. movf move f syntax: [ label ] movf f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: (f) ? (dest) status affected: z description: the contents of register f is moved to a destination dependent upon the status of d. if d = 0 , destination is w register. if d = 1 , the destination is file register f itself. d = 1 is useful to test a file register since status flag z is affected. words: 1 cycles: 1 example: movf fsr, 0 after instruction w= value in fsr register z= 1 movlw move literal to w syntax: [ label ] movlw k operands: 0 ? k ? 255 operation: k ? (w) status affected: none description: the eight-bit literal ?k? is loaded into w register. the ?don?t cares? will assemble as ? 0 ?s. words: 1 cycles: 1 example: movlw 0x5a after instruction w= 0x5a movwf move w to f syntax: [ label ] movwf f operands: 0 ? f ? 127 operation: (w) ? (f) status affected: none description: move data from w register to register ?f?. words: 1 cycles: 1 example: movw f option before instruction option = 0xff w = 0x4f after instruction option = 0x4f w = 0x4f nop no operation syntax: [ label ] nop operands: none operation: no operation status affected: none description: no operation. words: 1 cycles: 1 example: nop
? 2010 microchip technology inc. ds41417a-page 191 pic16f/lf722a/723a retfie return from interrupt syntax: [ label ] retfie operands: none operation: tos ? pc, 1 ? gie status affected: none description: return from interrupt. stack is poped and top-of-stack (tos) is loaded in the pc. interrupts are enabled by setting global interrupt enable bit, gie (intcon<7>). this is a two-cycle instruction. words: 1 cycles: 2 example: retfie after interrupt pc = tos gie = 1 retlw return with literal in w syntax: [ label ] retlw k operands: 0 ? k ? 255 operation: k ? (w); tos ? pc status affected: none description: the w register is loaded with the eight bit literal ?k?. the program counter is loaded from the top of the stack (the return address). this is a two-cycle instruction. words: 1 cycles: 2 example: table call table;w contains table ;offset value ? ;w now has table value ? ? addwf pc ;w = offset retlw k1 ;begin table retlw k2 ; ? ? ? retlw kn ; end of table before instruction w = 0x07 after instruction w = value of k8 return return from subroutine syntax: [ label ] return operands: none operation: tos ? pc status affected: none description: return from subroutine. the stack is poped and the top of the stack (tos) is loaded into the program counter. this is a two-cycle instruction.
pic16f/lf722a/723a ds41417a-page 192 ? 2010 microchip technology inc. rlf rotate left f through carry syntax: [ label ] rlf f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: see description below status affected: c description: the contents of register ?f? are rotated one bit to the left through the carry flag. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?. words: 1 cycles: 1 example: rlf reg1,0 before instruction reg1 = 1110 0110 c=0 after instruction reg1 = 1110 0110 w = 1100 1100 c=1 rrf rotate right f through carry syntax: [ label ] rrf f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: see description below status affected: c description: the contents of register ?f? are rotated one bit to the right through the carry flag. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. register f c register f c sleep enter sleep mode syntax: [ label ] sleep operands: none operation: 00h ? wdt, 0 ? wdt prescaler, 1 ? to , 0 ? pd status affected: to , pd description: the power-down status bit, pd is cleared. time-out status bit, to is set. watchdog timer and its prescaler are cleared. the processor is put into sleep mode with the oscillator stopped. sublw subtract w from literal syntax: [ label ] sublw k operands: 0 ?? k ?? 255 operation: k - (w) ??? w) status affected: c, dc, z description: the w register is subtracted (2?s complement method) from the eight-bit literal ?k?. the result is placed in the w register. c = 0 w ? k c = 1 w ? k dc = 0 w<3:0> ? k<3:0> dc = 1 w<3:0> ? k<3:0>
? 2010 microchip technology inc. ds41417a-page 193 pic16f/lf722a/723a subwf subtract w from f syntax: [ label ] subwf f,d operands: 0 ?? f ?? 127 d ? [ 0 , 1 ] operation: (f) - (w) ??? destination) status affected: c, dc, z description: subtract (2?s complement method) w register from register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f. swapf swap nibbles in f syntax: [ label ] swapf f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: (f<3:0>) ? (destination<7:4>), (f<7:4>) ? (destination<3:0>) status affected: none description: the upper and lower nibbles of register ?f? are exchanged. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed in register ?f?. c = 0 w ? f c = 1 w ? f dc = 0 w<3:0> ? f<3:0> dc = 1 w<3:0> ? f<3:0> xorlw exclusive or literal with w syntax: [ label ] xorlw k operands: 0 ?? k ?? 255 operation: (w) .xor. k ??? w) status affected: z description: the contents of the w register are xor?ed with the eight-bit literal ?k?. the result is placed in the w register. xorwf exclusive or w with f syntax: [ label ] xorwf f,d operands: 0 ? f ? 127 d ? [ 0 , 1 ] operation: (w) .xor. (f) ??? destination) status affected: z description: exclusive or the contents of the w register with register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?.
pic16f/lf722a/723a ds41417a-page 194 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 195 pic16f/lf722a/723a 22.0 development support the pic ? microcontrollers and dspic ? digital signal controllers are supported with a full range of software and hardware development tools: ? integrated development environment - mplab ? ide software ? compilers/assemblers/linkers - mplab c compiler for various device families - hi-tech c for various device families - mpasm tm assembler -mplink tm object linker/ mplib tm object librarian - mplab assembler/linker/librarian for various device families ? simulators - mplab sim software simulator ?emulators - mplab real ice? in-circuit emulator ? in-circuit debuggers - mplab icd 3 - pickit? 3 debug express ? device programmers - pickit? 2 programmer - mplab pm3 device programmer ? low-cost demonstration/development boards, evaluation kits, and starter kits 22.1 mplab integrated development environment software the mplab ide software brings an ease of software development previously unseen in the 8/16/32-bit microcontroller market. the mplab ide is a windows ? operating system-based application that contains: ? a single graphical interface to all debugging tools - simulator - programmer (sold separately) - in-circuit emulator (sold separately) - in-circuit debugger (sold separately) ? a full-featured editor with color-coded context ? a multiple project manager ? customizable data windows with direct edit of contents ? high-level source code debugging ? mouse over variable inspection ? drag and drop variables from source to watch windows ? extensive on-line help ? integration of select third party tools, such as iar c compilers the mplab ide allows you to: ? edit your source files (either c or assembly) ? one-touch compile or assemble, and download to emulator and simulator tools (automatically updates all project information) ? debug using: - source files (c or assembly) - mixed c and assembly - machine code mplab ide supports multiple debugging tools in a single development paradigm, from the cost-effective simulators, through low-cost in-circuit debuggers, to full-featured emulators. this eliminates the learning curve when upgrading to tools with increased flexibility and power.
pic16f/lf722a/723a ds41417a-page 196 ? 2010 microchip technology inc. 22.2 mplab c compilers for various device families the mplab c compiler code development systems are complete ansi c compilers for microchip?s pic18, pic24 and pic32 families of microcontrollers and the dspic30 and dspic33 families of digital signal control- lers. these compilers provide powerful integration capabilities, superior code optimization and ease of use. for easy source level debugging, the compilers provide symbol information that is optimized to the mplab ide debugger. 22.3 hi-tech c for various device families the hi-tech c compiler code development systems are complete ansi c compilers for microchip?s pic family of microcontrollers and the dspic family of digital signal controllers. these compilers provide powerful integration capabilities, omniscient code generation and ease of use. for easy source level debugging, the compilers provide symbol information that is optimized to the mplab ide debugger. the compilers include a macro assembler, linker, pre- processor, and one-step driver, and can run on multiple platforms. 22.4 mpasm assembler the mpasm assembler is a full-featured, universal macro assembler for pic10/12/16/18 mcus. the mpasm assembler generates relocatable object files for the mplink object linker, intel ? standard hex files, map files to detail memory usage and symbol reference, absolute lst files that contain source lines and generated machine code and coff files for debugging. the mpasm assembler features include: ? integration into mplab ide projects ? user-defined macros to streamline assembly code ? conditional assembly for multi-purpose source files ? directives that allow complete control over the assembly process 22.5 mplink object linker/ mplib object librarian the mplink object linker combines relocatable objects created by the mpasm assembler and the mplab c18 c compiler. it can link relocatable objects from precompiled libraries, using directives from a linker script. the mplib object librarian manages the creation and modification of library files of precompiled code. when a routine from a library is called from a source file, only the modules that contain that routine will be linked in with the application. this allows large libraries to be used efficiently in many different applications. the object linker/library features include: ? efficient linking of single libraries instead of many smaller files ? enhanced code maintainability by grouping related modules together ? flexible creation of libraries with easy module listing, replacement, deletion and extraction 22.6 mplab assembler, linker and librarian for various device families mplab assembler produces relocatable machine code from symbolic assembly language for pic24, pic32 and dspic devices. mplab c compiler uses the assembler to produce its object file. the assembler generates relocatable object files that can then be archived or linked with other relocatable object files and archives to create an executable file. notable features of the assembler include: ? support for the entire device instruction set ? support for fixed-point and floating-point data ? command line interface ? rich directive set ? flexible macro language ? mplab ide compatibility
? 2010 microchip technology inc. ds41417a-page 197 pic16f/lf722a/723a 22.7 mplab sim software simulator the mplab sim software simulator allows code development in a pc-hosted environment by simulat- ing the pic mcus and dspic ? dscs on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a comprehensive stimulus controller. registers can be logged to files for further run-time analysis. the trace buffer and logic analyzer display extend the power of the simulator to record and track program execution, actions on i/o, most peripherals and internal registers. the mplab sim software simulator fully supports symbolic debugging using the mplab c compilers, and the mpasm and mplab assemblers. the soft- ware simulator offers the flexibility to develop and debug code outside of the hardware laboratory envi- ronment, making it an excellent, economical software development tool. 22.8 mplab real ice in-circuit emulator system mplab real ice in-circuit emulator system is microchip?s next generation high-speed emulator for microchip flash dsc and mcu devices. it debugs and programs pic ? flash mcus and dspic ? flash dscs with the easy-to-use, powerful graphical user interface of the mplab integrated development environment (ide), included with each kit. the emulator is connected to the design engineer?s pc using a high-speed usb 2.0 interface and is connected to the target with either a connector compatible with in- circuit debugger systems (rj11) or with the new high- speed, noise tolerant, low-voltage differential signal (lvds) interconnection (cat5). the emulator is field upgradable through future firmware downloads in mplab ide. in upcoming releases of mplab ide, new devices will be supported, and new features will be added. mplab real ice offers signifi- cant advantages over competitive emulators including low-cost, full-speed emulation, run-time variable watches, trace analysis, complex breakpoints, a rugge- dized probe interface and long (up to three meters) inter- connection cables. 22.9 mplab icd 3 in-circuit debugger system mplab icd 3 in-circuit debugger system is micro- chip's most cost effective high-speed hardware debugger/programmer for microchip flash digital sig- nal controller (dsc) and microcontroller (mcu) devices. it debugs and programs pic ? flash microcon- trollers and dspic ? dscs with the powerful, yet easy- to-use graphical user interface of mplab integrated development environment (ide). the mplab icd 3 in-circuit debugger probe is con- nected to the design engineer's pc using a high-speed usb 2.0 interface and is connected to the target with a connector compatible with the mplab icd 2 or mplab real ice systems (rj-11). mplab icd 3 supports all mplab icd 2 headers. 22.10 pickit 3 in-circuit debugger/ programmer and pickit 3 debug express the mplab pickit 3 allows debugging and program- ming of pic ? and dspic ? flash microcontrollers at a most affordable price point using the powerful graphical user interface of the mplab integrated development environment (ide). the mplab pickit 3 is connected to the design engineer's pc using a full speed usb interface and can be connected to the target via an microchip debug (rj-11) connector (compatible with mplab icd 3 and mplab real ice). the connector uses two device i/o pins and the reset line to imple- ment in-circuit debugging and in-circuit serial pro- gramming?. the pickit 3 debug express include the pickit 3, demo board and microcontroller, hookup cables and cdrom with user?s guide, lessons, tutorial, compiler and mplab ide software.
pic16f/lf722a/723a ds41417a-page 198 ? 2010 microchip technology inc. 22.11 pickit 2 development programmer/debugger and pickit 2 debug express the pickit? 2 development programmer/debugger is a low-cost development tool with an easy to use inter- face for programming and debugging microchip?s flash families of microcontrollers. the full featured windows ? programming interface supports baseline (pic10f, pic12f5xx, pic16f5xx), midrange (pic12f6xx, pic16f), pic18f, pic24, dspic30, dspic33, and pic32 families of 8-bit, 16-bit, and 32-bit microcontrollers, and many microchip serial eeprom products. with microchip?s powerful mplab integrated development environment (ide) the pickit? 2 enables in-circuit debugging on most pic ? microcon- trollers. in-circuit-debugging runs, halts and single steps the program while the pic microcontroller is embedded in the application. when halted at a break- point, the file registers can be examined and modified. the pickit 2 debug express include the pickit 2, demo board and microcontroller, hookup cables and cdrom with user?s guide, lessons, tutorial, compiler and mplab ide software. 22.12 mplab pm3 device programmer the mplab pm3 device programmer is a universal, ce compliant device programmer with programmable voltage verification at v ddmin and v ddmax for maximum reliability. it features a large lcd display (128 x 64) for menus and error messages and a modu- lar, detachable socket assembly to support various package types. the icsp? cable assembly is included as a standard item. in stand-alone mode, the mplab pm3 device programmer can read, verify and program pic devices without a pc connection. it can also set code protection in this mode. the mplab pm3 connects to the host pc via an rs-232 or usb cable. the mplab pm3 has high-speed communications and optimized algorithms for quick programming of large memory devices and incorporates an mmc card for file storage and data applications. 22.13 demonstration/development boards, evaluation kits, and starter kits a wide variety of demonstration, development and evaluation boards for various pic mcus and dspic dscs allows quick application development on fully func- tional systems. most boards include prototyping areas for adding custom circuitry and provide application firmware and source code for examination and modification. the boards support a variety of features, including leds, temperature sensors, switches, speakers, rs-232 interfaces, lcd displays, potentiometers and additional eeprom memory. the demonstration and development boards can be used in teaching environments, for prototyping custom circuits and for learning about various microcontroller applications. in addition to the picdem? and dspicdem? demon- stration/development board series of circuits, microchip has a line of evaluation kits and demonstration software for analog filter design, k ee l oq ? security ics, can, irda ? , powersmart battery management, seeval ? evaluation system, sigma-delta adc, flow rate sensing, plus many more. also available are starter kits that contain everything needed to experience the specified device. this usually includes a single application and debug capability, all on one board. check the microchip web page (www.microchip.com) for the complete list of demonstration, development and evaluation kits.
? 2010 microchip technology inc. ds41417a-page 199 pic16f/lf722a/723a 23.0 electrical specifications absolute maximum ratings (?) ambient temperature under bias................................................................................................. ...... -40c to +125c storage temperature ............................................................................................................ ............ -65c to +150c voltage on v dd with respect to v ss , pic16f722a/723a ................................................................... -0.3v to +6.5v voltage on v cap pin with respect to v ss , pic16f722a/723a ............................................................ -0.3v to +4.0v voltage on v dd with respect to v ss , pic16lf722a/723a ................................................................. -0.3v to +4.0v voltage on mclr with respect to vss ................................................................................................. -0.3v to +9.0v voltage on all other pins with respect to v ss ........................................................................... -0.3v to (v dd + 0.3v) total power dissipation (1) ............................................................................................................................... 800 mw maximum current out of v ss pin ...................................................................................................................... 95 m a maximum current into v dd pin ......................................................................................................................... 7 0 ma clamp current, i k (v pin < 0 or v pin > v dd ) ??????????????????????????????????????????????????????????????? ??????????????????????????????????????????????????? 20 ma maximum output current sunk by any i/o pin..................................................................................... ............... 25 ma maximum output current sourced by any i/o pin .................................................................................. ............ 25 ma maximum current sunk by all ports (2) , -40c ? t a ? +85c for industrial ........................................................ 200 ma maximum current sunk by all ports (2) , -40c ? t a ? +125c for extended........................................................ 90 ma maximum current sourced by all ports (2) , 40c ? t a ? +85c for industrial ................................................... 140 ma maximum current sourced by all ports (2) , -40c ? t a ? +125c for extended................................................... 65 ma note 1: power dissipation is calculated as follows: p dis = v dd x {i dd ? ? i oh } + ? {(v dd ? v oh ) x i oh } + ? (v o l x i ol ). ? notice: stresses above those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure above maximum rating conditions for extended periods may affect device reliability.
pic16f/lf722a/723a ds41417a-page 200 ? 2010 microchip technology inc. 23.1 dc characteristics: pic16f/lf722a/723a-i/e (industrial, extended) pic16lf722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended pic16f722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param. no. sym. characteristic min. typ? max. units conditions d001 v dd supply voltage pic16lf722a/723a 1.8 1.8 2.3 2.5 ? ? ? ? 3.6 3.6 3.6 3.6 v v v v f osc ? 16 mhz: hfintosc, ec f osc ? 4mhz f osc ? 20 mhz, ec f osc ? 20 mhz, hs d001 pic16f722a/723a 1.8 1.8 2.3 2.5 ? ? ? ? 5.5 5.5 5.5 5.5 v v v v f osc ? 16 mhz: hfintosc, ec f osc ? 4 mhz f osc ? 20 mhz, ec f osc ? 20 mhz, hs d002* v dr ram data retention voltage (1) pic16lf722a/723a 1.5 ? ? v device in sleep mode d002* pic16f722a/723a 1.7 ? ? v device in sleep mode v por * power-on reset release voltage ?1.6? v v porr * power-on reset rearm voltage pic16lf722a/723a ? 0.8 ? v device in sleep mode pic16f722a/723a ? 1.7 ? v device in sleep mode d003 v fvr fixed voltage reference voltage, initial accuracy -5.5 -5.5 -5.5 ? ? ? 5.5 5.5 5.5 % % % v fvr = 1.024v, v dd ? 2.5v v fvr = 2.048v, v dd ? 2.5v v fvr = 4.096v, v dd ?? 4.75v; -40 ?? t a ??? 85c -6 -6 -6 ? ? ? 6 6 6 % % % v fvr = 1.024v, v dd ? 2.5v v fvr = 2.048v, v dd ? 2.5v v fvr = 4.096v, v dd ?? 4.75v; -40 ?? t a ??? 125c d004* s vdd v dd rise rate to ensure internal power-on reset signal 0.05 ? ? v/ms see section 3.2 ?power-on reset (por)? for details. * these parameters are characterized but not tested. ? data in ?typ? column is at 3.3v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data.
? 2010 microchip technology inc. ds41417a-page 201 pic16f/lf722a/723a figure 23-1: por and por rearm with slow rising v dd v dd v por v porr v ss v ss npor t por (3) por rearm note 1: when npor is low, the device is held in reset. 2: t por 1 ? s typical. 3: t vlow 2.7 ? s typical. t vlow (2)
pic16f/lf722a/723a ds41417a-page 202 ? 2010 microchip technology inc. 23.2 dc characteristics: pic16f/lf722a/723a-i/e (industrial, extended) pic16lf722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended pic16f722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. device characteristics min. typ? max. units conditions v dd note supply current (i dd ) (1, 2) d009 ldo regulator ? 350 ? ? a ? hs, ec or intosc/intoscio (8-16 mh z ) clock modes with all v cap pins disabled ? 50 ? ? a ? all v cap pins disabled ? 30 ? ? a ? v cap enabled on ra0, ra5 or ra6 ? 5 ? ? a ? lp clock mode and sleep (requires fvr and bor to be disabled) d010 ? 7.0 12 ? a1.8f osc = 32 khz lp oscillator mode (note 4) , -40c ? t a ? +85c ?9.0 14 ? a3.0 d010 ? 11 20 ? a 1.8 f osc = 32 khz lp oscillator mode (note 4) , -40c ? t a ? +85c ? 14 22 ? a 3.0 ? 15 24 ? a 5.0 d011 ? 7.0 12 ? a1.8 f osc = 32 khz lp oscillator mode -40c ? t a ? +125c ?9.0 18 ? a3.0 d011 ? 11 21 ? a 1.8 f osc = 32 khz lp oscillator mode (note 4) -40c ? t a ? +125c ? 14 25 ? a 3.0 ? 15 27 ? a 5.0 d011 ? 110 150 ? a1.8f osc = 1 mhz xt oscillator mode ? 150 215 ? a3.0 d011 ? 120 175 ? a 1.8 f osc = 1 mhz xt oscillator mode (note 5) ? 180 250 ? a 3.0 ? 240 300 ? a 5.0 d012 ? 230 300 ? a1.8f osc = 4 mhz xt oscillator mode ? 400 600 ? a3.0 d012 ? 250 350 ? a 1.8 f osc = 4 mhz xt oscillator mode (note 5) ? 420 650 ? a 3.0 ? 500 750 ? a 5.0 d013 ? 125 180 ? a1.8f osc = 1 mhz ec oscillator mode ? 230 270 ? a3.0 d013 ? 150 205 ? a 1.8 f osc = 1 mhz ec oscillator mode (note 5) ? 225 320 ? a 3.0 ? 250 410 ? a 5.0 note 1: the test conditions for all i dd measurements in active operation mode ar e: osc1 = external square wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and frequency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pa ttern and temperature, also have an impact on the current consumption. 3: for rc oscillator configurations, current through r ext is not included. the current through the resistor can be extended by the formula i r = v dd /2r ext (ma) with r ext in k ?? 4: fvr and bor are disabled. 5: 0.1 ? f capacitor on v cap (ra0).
? 2010 microchip technology inc. ds41417a-page 203 pic16f/lf722a/723a supply current (i dd ) (1, 2) d014 ? 290 330 ? a1.8f osc = 4 mhz ec oscillator mode ? 460 500 ? a3.0 d014 ? 300 430 ? a 1.8 f osc = 4 mhz ec oscillator mode (note 5) ? 450 655 ? a 3.0 ? 500 730 ? a 5.0 d015 ? 100 130 ? a1.8f osc = 500 khz mfintosc mode ? 120 150 ? a3.0 d015 ? 115 195 ? a 1.8 f osc = 500 khz mfintosc mode (note 5) ? 135 200 ? a 3.0 ? 150 220 ? a 5.0 d016 ? 650 800 ? a1.8f osc = 8 mhz hfintosc mode ? 1000 1200 ? a3.0 d016 ? 625 850 ? a 1.8 f osc = 8 mhz hfintosc mode (note 5) ? 1000 1200 ? a 3.0 ? 1100 1500 ? a 5.0 d017 ? 1.0 1.2 ma 1.8 f osc = 16 mhz hfintosc mode ? 1.5 1.85 ma 3.0 d017 ? 1 1.2 ma 1.8 f osc = 16 mhz hfintosc mode (note 5) ? 1.5 1.7 ma 3.0 ? 1.7 2.1 ma 5.0 d018 ? 210 240 ? a1.8f osc = 4 mhz extrc mode (note 3, note 5) ? 340 380 ? a3.0 d018 ? 225 320 ? a 1.8 f osc = 4 mhz extrc mode (note 3, note 5) ? 360 445 ? a 3.0 ? 410 650 ? a 5.0 d019 ? 1.6 1.9 ma 3.0 f osc = 20 mhz hs oscillator mode ?2.02.8ma 3.6 d019 ? 1.6 2 ma 3.0 f osc = 20 mhz hs oscillator mode (note 5) ? 1.9 3.2 ma 5.0 23.2 dc characteristics: pic16f/lf722a/723a-i/e (industrial, extended) (continued) pic16lf722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended pic16f722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. device characteristics min. typ? max. units conditions v dd note note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external square wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and frequency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pa ttern and temperature, also have an impact on the current consumption. 3: for rc oscillator configurations, current through r ext is not included. the current through the resistor can be extended by the formula i r = v dd /2r ext (ma) with r ext in k ?? 4: fvr and bor are disabled. 5: 0.1 ? f capacitor on v cap (ra0).
pic16f/lf722a/723a ds41417a-page 204 ? 2010 microchip technology inc. 23.3 dc characteristics: pic16f/lf722a/723a-i/e (power-down) pic16lf722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended pic16f722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. device characteristics min. typ? max. +85c max. +125c units conditions v dd note power-down base current (i pd ) (2) d020 ? 0.02 0.7 3.9 ? a 1.8 wdt, bor, fvr, and t1osc disabled, all peripherals inactive ? 0.08 1.0 4.3 ? a3.0 d020 ? 4.3 10.2 17 ? a 1.8 wdt, bor, fvr, and t1osc disabled, all peripherals inactive ? 5 10.5 18 ? a 3.0 ? 5.5 11.8 21 ? a 5.0 d021 ? 0.5 1.7 4.1 ? a 1.8 lpwdt current (note 1) ? 0.8 2.5 4.8 ? a3.0 d021 ? 6 13.5 16.4 ? a 1.8 lpwdt current (note 1) ? 6.5 14.5 16.8 ? a 3.0 ? 7.5 16 18.7 ? a 5.0 d021a ? 8.5 14 19 ? a 1.8 fvr current (note 1. note 3) ? 8.5 14 20 ? a3.0 d021a ? 23 44 48 ? a 1.8 fvr current (note 1, note 3, note 5) ? 25 45 55 ? a 3.0 ? 26 60 70 ? a 5.0 d022 ? ? ? ? ? a 1.8 bor current (note 1, note 3) ? 7.5 12 22 ? a3.0 d022 ? ? ? ? ? a 1.8 bor current (note 1, note 3, note 5) ? 23 42 49 ? a 3.0 ? 25 46 50 ? a 5.0 d026 ? 0.6 2 ? ? a 1.8 t1osc current (note 1) ?1.83.0 ? ? a3.0 d026 ? 4.5 11.1 ? ? a 1.8 t1osc current (note 1) ? 6 12.5 ? ? a 3.0 ? 7 13.5 ? ? a 5.0 ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral ? current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 2: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in high-impedance state and tied to v dd . 3: fixed voltage reference is automatic ally enabled whenever the bor is enabled. 4: a/d oscillator source is f rc . 5: 0.1 ? f capacitor on v cap (ra0).
? 2010 microchip technology inc. ds41417a-page 205 pic16f/lf722a/723a power-down base current (i pd ) (2) d027 ? 0.06 0.7 5.0 ? a 1.8 a/d current (note 1, note 4) , no conversion in progress ? 0.08 1.0 5.5 ? a3.0 d027 ? 6 10.7 18 ? a 1.8 a/d current (note 1, note 4) , no conversion in progress ? 7 10.6 20 ? a 3.0 ? 7.2 11.9 22 ? a 5.0 d027a ? 250 400 ? ? a 1.8 a/d current (note 1, note 4) , conversion in progress ? 250 400 ? ? a3.0 d027a ? 280 430 ? ? a 1.8 a/d current (note 1, note 4, note 5) , conversion in progress ? 280 430 ? ? a 3.0 ? 280 430 ? ? a 5.0 d028 ? 2.2 3.2 14.4 ? a 1.8 cap sense low power oscillator mode ?3.34.415.6 ? a3.0 d028 ? 6.5 13 21 ? a 1.8 cap sense low power oscillator mode ? 8 14 23 ? a 3.0 ? 8 14 25 ? a 5.0 d028a ? 4.2 6 17 ? a 1.8 cap sense medium power oscillator mode ?6 7 18 ? a3.0 d028a ? 8.5 15.5 23 ? a 1.8 cap sense medium power oscillator mode ? 11 17 24 ? a 3.0 ? 11 18 27 ? a 5.0 d028b ? 12 14 25 ? a 1.8 cap sense high power oscillator mode ?32 35 44 ? a3.0 d028b ? 16 20 31 ? a 1.8 cap sense high power oscillator mode ? 36 41 50 ? a 3.0 ? 42 49 58 ? a 5.0 23.3 dc characteristics: pic16f/lf722a/723a-i/e (power-down) (continued) pic16lf722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended pic16f722a/723a standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. device characteristics min. typ? max. +85c max. +125c units conditions v dd note ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral ? current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 2: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in high-impedance state and tied to v dd . 3: fixed voltage reference is automatic ally enabled whenever the bor is enabled. 4: a/d oscillator source is f rc . 5: 0.1 ? f capacitor on v cap (ra0).
pic16f/lf722a/723a ds41417a-page 206 ? 2010 microchip technology inc. 23.4 dc characteristics: pic16f/lf722a/723a-i/e dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym. characteristic min. typ? max. units conditions v il input low voltage i/o port: d030 with ttl buffer ? ? 0.8 v 4.5v ? v dd ? 5.5v d030a ? ? 0.15 v dd v1.8v ? v dd ? 4.5v d031 with schmitt trigger buffer ? ? 0.2 v dd v2.0v ? v dd ? 5.5v with i 2 c? levels ? ? 0.3 v dd v d032 mclr , osc1 (rc mode) (1) ??0.2v dd v d033a osc1 (hs mode) ? ? 0.3 v dd v v ih input high voltage i/o ports: ? ? d040 with ttl buffer 2.0 ? ? v 4.5v ? v dd ?? 5.5v d040a 0.25 v dd + 0.8 ??v1.8v ? v dd ? 4.5v d041 with schmitt trigger buffer 0.8 v dd ??v2.0v ? v dd ? 5.5v with i 2 c? levels 0.7 v dd ??v d042 mclr 0.8 v dd ??v d043a osc1 (hs mode) 0.7 v dd ??v d043b osc1 (rc mode) 0.9 v dd ??v (note 1) i il input leakage current (2) d060 i/o ports ? 5 5 125 1000 na na v ss ? v pin ? v dd , pin at high- impedance, 85c 125c d061 mclr (3) ? 50 200nav ss ? v pin ? v dd , 85c i pur portb weak pull-up current d070* 25 25 100 140 200 300 ? a v dd = 3.3v, v pin = v ss v dd = 5.0v, v pin = v ss v ol output low voltage (4) d080 i/o ports ??0.6v i ol = 8ma, v dd = 5v i ol = 6ma, v dd = 3.3v i ol = 1.8ma, v dd = 1.8v v oh output high voltage (4) d090 i/o ports v dd - 0.7 ? ? v i oh = 3.5ma, v dd = 5v i oh = 3ma, v dd = 3.3v i oh = 1ma, v dd = 1.8v capacitive loading specs on output pins d101* cosc2 osc2 pin ? ? 15 pf in xt, hs and lp modes when external clock is used to drive osc1 d101a* c io all i/o pins ? ? 50 pf legend: tbd = to be determined * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1/clkin pin is a schmitt trigger input. it is not recommended to use an external clock in rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 4: including osc2 in clkout mode.
? 2010 microchip technology inc. ds41417a-page 207 pic16f/lf722a/723a program flash memory d130 e p cell endurance 100 1k ? e/w temper ature during programming: 10c ? t a ? 40c d131 v dd for read v min ??v voltage on mclr /v pp during erase/program 8.0 ? 9.0 v temperature during programming: 10c ? t a ? 40c v dd for bulk erase 2.7 3 ? v temperature during programming: 10c ? t a ? 40c d132 v pew v dd for write or row erase 2.7 ? ? v v min = minimum operating voltage v max = maximum operating voltage i pppgm current on mclr /v pp during erase/write ??5.0ma temperature during programming: 10c ? t a ? 40c i ddpgm current on v dd during erase/ write ? 5.0 ma temperature during programming: 10c ? t a ? 40c d133 t pew erase/write cycle time ? 2.8 ms temperature during programming: 10c ? t a ? 40c d134 t retd characteristic retention 40 ? ? year pr ovided no other specifications are violated v cap capacitor charging d135 charging current ? 200 ? ? a d135a source/sink capability when charging complete ?0.0?ma 23.4 dc characteristics: pic16f/lf722a/723a-i/e (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym. characteristic min. typ? max. units conditions legend: tbd = to be determined * these parameters are char acterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1/clkin pin is a sc hmitt trigger input. it is not recommended to use an external clock in rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 4: including osc2 in clkout mode.
pic16f/lf722a/723a ds41417a-page 208 ? 2010 microchip technology inc. 23.5 thermal considerations standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +125c param no. sym. characteristic typ. units conditions th01 ? ja thermal resistance junction to ambient 60 ? c/w 28-pin spdip package 80 ? c/w 28-pin soic package 90 ? c/w 28-pin ssop package 27.5 ? c/w 28-pin uqfn 4x4mm package 27.5 ? c/w 28-pin qfn 6x6mm package th02 ? jc thermal resistance junction to case 31.4 ? c/w 28-pin spdip package 24 ? c/w 28-pin soic package 24 ? c/w 28-pin ssop package 24 ? c/w 28-pin uqfn 4x4mm package 24 ? c/w 28-pin qfn 6x6mm package th03 t jmax maximum junction temperature 150 ? c th04 pd power dissipation ? w pd = p internal + p i / o th05 p internal internal power dissipation ? w p internal = i dd x v dd (1) th06 p i / o i/o power dissipation ? w p i / o = ? (i ol * v ol ) + ? (i oh * (v dd - v oh )) th07 p der derated power ? w p der = pd max (t j - t a )/ ? ja (2) note 1: i dd is current to run the chip alone wit hout driving any load on the output pins. 2: t a = ambient temperature 3: t j = junction temperature
? 2010 microchip technology inc. ds41417a-page 209 pic16f/lf722a/723a 23.6 timing parameter symbology the timing parameter symbols have been created with one of the following formats: figure 23-2: load conditions 1. tpps2pps 2. tpps t f frequency t time lowercase letters (pp) and their meanings: pp cc ccp1 osc osc1 ck clkout rd rd cs cs rw rd or wr di sdi sc sck do sdo ss ss dt data in t0 t0cki io i/o port t1 t1cki mc mclr wr wr uppercase letters and their meanings: s ffall pperiod hhigh rrise i invalid (high-impedance) v valid l low z high-impedance v ss c l legend: c l = 50 pf for all pins, 15 pf for osc2 output load condition pin
pic16f/lf722a/723a ds41417a-page 210 ? 2010 microchip technology inc. 23.7 ac characteristics: pic16f722a/723a-i/e figure 23-3: clock timing figure 23-4: pic16f722a/723a voltage frequency graph, -40c ? t a ?? +125c osc1/clkin osc2/clkout q4 q1 q2 q3 q4 q1 os02 os03 os04 os04 osc2/clkout (lp,xt,hs modes) (clkout mode) 1.8 2.5 2.0 0 2.3 frequency (mhz) v dd (v) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 2: refer to table 23-1 for each oscillator mode?s supported frequencies. 420 10 16 5.5 3.6
? 2010 microchip technology inc. ds41417a-page 211 pic16f/lf722a/723a figure 23-5: pic16lf722a/723a vo ltage frequency graph, -40c ? t a ?? +125c figure 23-6: hfintosc frequency accuracy over device v dd and temperature 1.8 2.5 2.0 0 2.3 frequency (mhz) v dd (v) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 2: refer to table 23-1 for each oscillator mode?s supported frequencies. 420 10 16 3.6 125 25 2.0 0 60 85 v dd (v) 4.0 5.0 4.5 temperature ( c ) 2.5 3.0 3.5 5.5 1.8 note 1: this chart covers both regulator enabled and regulator disabled states. 2: regulator nominal voltage. 3.3 (2) -40 -20 + 5% 2% + 5% 3%
pic16f/lf722a/723a ds41417a-page 212 ? 2010 microchip technology inc. table 23-1: clock oscillator timing requirements standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +125c param no. sym. characteristic min. typ? max. units conditions os01 f osc external clkin frequency (1) dc ? 37 khz lp oscillator mode dc ? 4 mhz xt oscillator mode dc ? 20 mhz hs oscillator mode dc ? 20 mhz ec oscillator mode oscillator frequency (1) ? 32.768 ? khz lp oscillator mode 0.1 ? 4 mhz xt oscillator mode 1 ? 20 mhz hs oscillator mode, v dd ?? 2.7v ? dc ? 4 mhz rc oscillator mode os02 t osc external clkin period (1) 27 ? ?? s lp oscillator mode 250 ? ? ns xt oscillator mode 50 ? ? ns hs oscillator mode 50 ? ? ns ec oscillator mode oscillator period (1) ? 30.5 ? ? s lp oscillator mode 250 ? 10,000 ns xt oscillator mode 50 ? 1,000 ns hs oscillator mode, v dd ?? 2.7v 250 ? ? ns rc oscillator mode os03 t cy instruction cycle time (1) 200 t cy dc ns t cy = 4/f osc os04* tosh, to sl external clkin high, external clkin low 2?? ? s lp oscillator 100 ? ? ns xt oscillator 20 ? ? ns hs oscillator os05* tosr, to sf external clkin rise, external clkin fall 0? ? ns lp oscillator 0? ? ns xt oscillator 0? ? ns hs oscillator * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stat ed. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstabl e oscillator operation and/or hi gher than expected current consumption. all devices are tested to operate at ?min? va lues with an external clock applied to osc1 pin. when an external clock input is used, the ?max? cycle ti me limit is ?dc? (no clock) for all devices.
? 2010 microchip technology inc. ds41417a-page 213 pic16f/lf722a/723a table 23-2: oscillator parameters figure 23-7: clkout and i/o timing standard operating conditions (unless otherwise stated) operating temperature -40c ?? t a ?? +125c param no. sym. characteristic freq. tolerance min. typ? max. units conditions os08 hf osc internal calibrated hfintosc frequency (2) ? 2% ? 16.0 ? mhz 0c ? t a ? +85c, v dd ????? v ? 5% ? 16.0 ? mhz -40c ? t a ? +125c os08a mf osc internal calibrated mfintosc frequency (2) ? 2% ? 500 ? khz 0c ? t a ? +85c v dd ????? v ? 5% ? 500 10 khz -40c ? t a ? +125c os10* t iosc st hfintosc wake-up from sleep start-up time ??58 ? s mfintosc wake-up from sleep start-up time ? ? 20 30 ? s * these parameters are char acterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time bas e period. all specified values are based on characterization data for that particular oscillator ty pe under standard operating conditions with the device executing code. exceeding these specified limits may result in an uns table oscillator operation and/o r higher than expected current consumption. all devices are tested to operate at ?min? valu es with an external clock applied to the osc1 pin. when an external clock input is used, the ?max? cycle ti me limit is ?dc? (no clock) for all devices. 2: to ensure these oscillator frequency tolerances, v dd and v ss must be capacitively decoupled as close to the device as possible. 0.1 ? f and 0.01 ? f values in parallel are recommended. 3: by design. f osc clkout i/o pin (input) i/o pin (output) q4 q1 q2 q3 os11 os19 os13 os15 os18, os19 os20 os21 os17 os16 os14 os12 os18 old value new value write fetch read execute cycle
pic16f/lf722a/723a ds41417a-page 214 ? 2010 microchip technology inc. table 23-3: clkout and i/o timing parameters figure 23-8: reset, watchdog timer, os cillator start-up timer and power-up timer timing standard operating conditions (unless otherwise stated) operating temperature -40c ?? t a ?? +125c param no. sym. characteristic min. typ? max. units conditions os11 tosh2ckl fosc ? to clkout ? (1) ??70nsv dd = 3.3-5.0v os12 tosh2ckh fosc ? to clkout ? (1) ??72nsv dd = 3.3-5.0v os13 tckl2iov clkout ? to port out valid (1) ??20ns os14 tiov2ckh port input valid before clkout ? (1) t osc + 200 ns ? ? ns os15 tosh2iov fosc ? (q1 cycle) to port out valid ? 50 70* ns v dd = 3.3-5.0v os16 tosh2ioi fosc ? (q2 cycle) to port input invalid (i/o in hold time) 50 ? ? ns v dd = 3.3-5.0v os17 tiov2osh port input valid to fosc ?? (q2 cycle) (i/o in setup time) 20 ? ? ns os18 tior port output rise time (2) ? ? 40 15 72 32 ns v dd = 2.0v v dd = 3.3-5.0v os19 tiof port output fall time (2) ? ? 28 15 55 30 ns v dd = 2.0v v dd = 3.3-5.0v os20* tinp int pin input high or low time 25 ? ? ns os21* trbp portb interrupt-on-change new input level time t cy ??ns * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25 ? c unless otherwise stated. note 1: measurements are taken in rc mode where clkout output is 4 x t osc . 2: includes osc2 in clkout mode. v dd mclr internal por pwrt time-out osc start-up time internal reset (1) watchdog timer 33 32 30 31 34 i/o pins 34 note 1: asserted low. reset (1)
? 2010 microchip technology inc. ds41417a-page 215 pic16f/lf722a/723a figure 23-9: brown-out rese t timing and characteristics v bor v dd (device in brown-out reset) (device not in brown-out reset) 33 (1) note 1: 64 ms delay only if pwrte bit in the configuration word register is programmed to ? 0 ?. 2 ms delay if pwrte = 0 and vregen = 1 . reset (due to bor) v bor and v hyst 37
pic16f/lf722a/723a ds41417a-page 216 ? 2010 microchip technology inc. table 23-4: reset, watchdog timer, oscill ator start-up timer, power-up timer, and brown-out reset parameters figure 23-10: timer0 and time r1 external clock timings standard operating conditions (unless otherwise stated) operating temperature -40c ?? t a ?? +125c param no. sym. characteristic min. typ? max. units conditions 30 t mc lmclr pulse width (low) 2 5 ? ? ? ? ? s ? s v dd = 3.3-5v, -40c to +85c v dd = 3.3-5v 31 t wdtlp low power watchdog timer time- out period (no prescaler) 10 18 27 ms v dd = 3.3v-5v 32 t ost oscillator start-up timer period (1), (2) ? 1024 ? tosc (note 3) 33* t pwrt power-up timer period, pwrte = 0 40 65 140 ms 34* t ioz i/o high-impedance from mclr low or watchdog timer reset ??2.0 ? s 35 v bor brown-out reset voltage 2.38 1.80 2.5 1.9 2.73 2.11 vborv=2.5v borv=1.9v 36* v hyst brown-out reset hysteresis 0 25 50 mv -40c to +85c 37* t bordc brown-out reset dc response time 135 10 ? sv dd ? v bor , -40c to +85c v dd ? v bor * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstable oscillator operation and/or higher than expected current consumption. all devices ar e tested to operate at ?min? values with an external clock applied to the osc1 pin. when an external clock input is used, the ?max? cycle time limit is ?dc? (no clock) for all devices. 2: by design. 3: period of the slower clock. 4: to ensure these voltage tolerances, v dd and v ss must be capacitively decoupled as close to the device as possible. 0.1 ? f and 0.01 ? f values in parallel are recommended. t0cki t1cki 40 41 42 45 46 47 49 tmr0 or tmr1
? 2010 microchip technology inc. ds41417a-page 217 pic16f/lf722a/723a table 23-5: timer0 and timer1 external clock requirements figure 23-11: capture/com pare/pwm timings (ccp) table 23-6: capture/compare/pwm requirements (ccp) standard operating conditions (unless otherwise stated) operating temperature -40c ?? t a ?? +125c param no. sym. characteristic min. typ? max. units conditions 40* t t 0h t0cki high pulse width no prescaler 0.5 t cy + 20 ? ? ns with prescaler 10 ? ? ns 41* t t 0l t0cki low pulse width no prescaler 0.5 t cy + 20 ? ? ns with prescaler 10 ? ? ns 42* t t 0p t0cki period greater of: 20 or t cy + 40 n ? ? ns n = prescale value (2, 4, ..., 256) 45* t t 1h t1cki high time synchronous, no prescaler 0.5 t cy + 20 ? ? ns synchronous, with prescaler 15 ? ? ns asynchronous 30 ? ? ns 46* t t 1l t1cki low time synchronous, no prescaler 0.5 t cy + 20 ? ? ns synchronous, with prescaler 15 ? ? ns asynchronous 30 ? ? ns 47* t t 1p t1cki input period synchronous greater of: 30 or t cy + 40 n ? ? ns n = prescale value (1, 2, 4, 8) asynchronous 60 ? ? ns 48 f t 1 timer1 oscillator input frequency range (oscillator enabled by setting bit t1oscen) 32.4 32.768 33.1 khz 49* tckez tmr 1 delay from external clock edge to timer increment 2 t osc ?7 t osc ? timers in sync mode * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stat ed. these parameters are for design guidance only and are not tested. standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +125c param no. sym. characteristic min. typ? max. units conditions cc01* tccl ccpx input low time no prescaler 0.5t cy + 20 ? ? ns with prescaler 20 ? ? ns cc02* tcch ccpx input high time no prescaler 0.5t cy + 20 ? ? ns with prescaler 20 ? ? ns cc03* tccp ccpx input period 3t cy + 40 n ? ? ns n = prescale value (1, 4 or 16) * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are fo r design guidance only and are not tested. note: refer to figure 23-2 for load conditions. (capture mode) cc01 cc02 cc03 ccpx
pic16f/lf722a/723a ds41417a-page 218 ? 2010 microchip technology inc. table 23-7: pic16f722a/723a a/d converter (adc) characteristics : table 23-8: pic16f722a/723a a/d conversion requirements standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +125c param no. sym. characteristic min. typ? max. units conditions ad01 n r resolution ? ? 8 bit ad02 e il integral error ? ? 1.7 lsb v ref = 3.0v ad03 e dl differential error ? ? 1 lsb no missing codes v ref = 3.0v ad04 e off offset error ? ? 2.2 lsb v ref = 3.0v ad05 e gn gain error ? ? 1.5 lsb v ref = 3.0v ad06 v ref reference voltage (3) 1.8 ? v dd v ad07 v ain full-scale range v ss ?v ref v ad08 z ain recommended impedance of analog voltage source ?? 50 k ? can go higher if external 0.01 ? f capacitor is present on input pin. ? data in ?typ? column is at 3.0v, 25c unless otherwise stat ed. these parameters are for design guidance only and are not tested. note 1: total absolute error includes integral, differential, offset and gain errors. 2: the a/d conversion result never dec reases with an increase in the input voltage and has no missing codes. 3: when adc is off, it will not consume any current other than leakage current. the power-down current specification includes any such leakage from the adc module. standard operating conditions (unless otherwise stated) operating temperature -40c ? t a ? +125c param no. sym. characteristic min. typ? max. units conditions ad130* t ad a/d clock period 1.0 ? 9.0 ? st osc -based a/d internal rc oscillator period 1.0 2.0 6.0 ? s adcs<1:0> = 11 (adrc mode) ad131 t cnv conversion time (not including acquisition time) (1) ? 10.5 ? t ad set go/done bit to conversion complete ad132* t acq acquisition time ? 1.0 ? ? s * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the adres register may be read on the following t cy cycle.
? 2010 microchip technology inc. ds41417a-page 219 pic16f/lf722a/723a figure 23-12: pic16f722a/723a a/d conversion timing (normal mode) figure 23-13: pic16f722a/723a a/d conversion timing (sleep mode) ad131 ad130 bsf adcon0, go q4 a/d clk a/d data adres adif go sample old_data sampling stopped done new_data 765 3210 note 1: if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. 1 t cy 4 ad134 (t osc /2 (1) ) 1 t cy ad132 ad132 ad131 ad130 bsf adcon0, go q4 a/d clk a/d data adres adif go sample old_data sampling stopped done new_data 7 5 3210 note 1: if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. ad134 4 6 1 t cy (t osc /2 + t cy (1) ) 1 t cy
pic16f/lf722a/723a ds41417a-page 220 ? 2010 microchip technology inc. figure 23-14: usart synchronous transmission (master/slave) timing table 23-9: usart synchronous tran smission requirements figure 23-15: usart synchrono us receive (master/slave) timing table 23-10: usart synchronous rece ive requirements standard operating conditions (unless otherwise stated) operating temperature -40c ?? t a ?? +125c param. no. symbol characteristic min. max. units conditions us120 t ck h2 dt v sync xmit (m aster and s lave ) clock high to data-out valid 3.0-5.5v ? 80 ns 1.8-5.5v ? 100 ns us121 t ckrf clock out rise time and fall time (master mode) 3.0-5.5v ? 45 ns 1.8-5.5v ? 50 ns us122 t dtrf data-out rise time and fall time 3.0-5.5v ? 45 ns 1.8-5.5v ? 50 ns standard operating conditions (unless otherwise stated) operating temperature -40c ?? t a ?? +125c param. no. symbol characteristic min. max. units conditions us125 t dt v2 ckl sync rcv (m aster and s lave ) data-hold before ck ? (dt hold time) 10 ? ns us126 t ck l2 dtl data-hold after ck ? (dt hold time) 15 ? ns note: refer to figure 23-2 for load conditions. us121 us121 us120 us122 ck dt note: refer to figure 23-2 for load conditions. us125 us126 ck dt
? 2010 microchip technology inc. ds41417a-page 221 pic16f/lf722a/723a figure 23-16: spi master mode timing (cke = 0 , smp = 0 ) figure 23-17: spi master mode timing (cke = 1 , smp = 1 ) ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi sp70 sp71 sp72 sp73 sp74 sp75, sp76 sp78 sp79 sp80 sp79 sp78 msb lsb bit 6 - - - - - -1 msb in lsb in bit 6 - - - -1 note: refer to figure 23-2 for load conditions. ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi sp81 sp71 sp72 sp74 sp75, sp76 sp78 sp80 msb sp79 sp73 msb in bit 6 - - - - - -1 lsb in bit 6 - - - -1 lsb note: refer to figure 23-2 for load conditions.
pic16f/lf722a/723a ds41417a-page 222 ? 2010 microchip technology inc. figure 23-18: spi slav e mode timing (cke = 0 ) figure 23-19: spi slav e mode timing (cke = 1 ) ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi sp70 sp71 sp72 sp73 sp74 sp75, sp76 sp77 sp78 sp79 sp80 sp79 sp78 msb lsb bit 6 - - - - - -1 msb in bit 6 - - - -1 lsb in sp83 note: refer to figure 23-2 for load conditions. ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi sp70 sp71 sp72 sp82 sp74 sp75, sp76 msb bit 6 - - - - - -1 lsb sp77 msb in bit 6 - - - -1 lsb in sp80 sp83 note: refer to figure 23-2 for load conditions.
? 2010 microchip technology inc. ds41417a-page 223 pic16f/lf722a/723a table 23-11: spi mode requirements figure 23-20: i 2 c? bus start/stop bits timing param no. symbol characteristic min. typ? max. units conditions sp70* t ss l2 sc h, t ss l2 sc l ss ? to sck ? or sck ? input t cy ??ns sp71* t sc h sck input high time (slave mode) t cy + 20 ? ? ns sp72* t sc l sck input low time (slave mode) t cy + 20 ? ? ns sp73* t di v2 sc h, t di v2 sc l setup time of sdi data input to sck edge 100 ? ? ns sp74* t sc h2 di l, t sc l2 di l hold time of sdi data input to sck edge 100 ? ? ns sp75* t do r sdo data output rise time 3.0-5.5v ? 10 25 ns 1.8-5.5v ? 25 50 ns sp76* t do f sdo data output fall time ? 10 25 ns sp77* t ss h2 do zss ? to sdo output high-impedance 10 ? 50 ns sp78* t sc r sck output rise time (master mode) 3.0-5.5v ? 10 25 ns 1.8-5.5v ? 25 50 ns sp79* t sc f sck output fall time (master mode) ? 10 25 ns sp80* t sc h2 do v, t sc l2 do v sdo data output valid after sck edge 3.0-5.5v ? ? 50 ns 1.8-5.5v ? ? 145 ns sp81* t do v2 sc h, t do v2 sc l sdo data output setup to sck edge tcy ? ? ns sp82* t ss l2 do v sdo data output valid after ss ? edge ? ? 50 ns sp83* t sc h2 ss h, t sc l2 ss h ss ?? after sck edge 1.5t cy + 40 ? ? ns * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note: refer to figure 23-2 for load conditions. sp91 sp92 sp93 scl sda start condition stop condition sp90
pic16f/lf722a/723a ds41417a-page 224 ? 2010 microchip technology inc. table 23-12: i 2 c? bus start/stop bits requirements figure 23-21: i 2 c? bus data timing param no. symbol characteristic min. typ max. units conditions sp90* t su : sta start condition 100 khz mode 4700 ? ? ns only relevant for repeated start condition setup time 400 khz mode 600 ? ? sp91* t hd : sta start condition 100 khz mode 4000 ? ? ns after this period, the first clock pulse is generated hold time 400 khz mode 600 ? ? sp92* t su : sto stop condition 100 khz mode 4700 ? ? ns setup time 400 khz mode 600 ? ? sp93 t hd : sto stop condition 100 khz mode 4000 ? ? ns hold time 400 khz mode 600 ? ? * these parameters are characterized but not tested. note: refer to figure 23-2 for load conditions. sp90 sp91 sp92 sp100 sp101 sp103 sp106 sp107 sp109 sp109 sp110 sp102 scl sda in sda out
? 2010 microchip technology inc. ds41417a-page 225 pic16f/lf722a/723a table 23-13: i 2 c? bus data requirements param. no. symbol characteristic min. max. units conditions sp100* t high clock high time 100 khz mode 4.0 ? ? s device must operate at a minimum of 1.5 mhz 400 khz mode 0.6 ? ? s device must operate at a minimum of 10 mhz ssp module 1.5t cy ? sp101* t low clock low time 100 khz mode 4.7 ? ? s device must operate at a minimum of 1.5 mhz 400 khz mode 1.3 ? ? s device must operate at a minimum of 10 mhz ssp module 1.5t cy ? sp102* t r sda and scl rise time 100 khz mode ? 1000 ns 400 khz mode 20 + 0.1c b 300 ns c b is specified to be from 10-400 pf sp103* t f sda and scl fall time 100 khz mode ? 250 ns 400 khz mode 20 + 0.1c b 250 ns c b is specified to be from 10-400 pf sp106* t hd : dat data input hold time 100 khz mode 0 ? ns 400 khz mode 0 0.9 ? s sp107* t su : dat data input setup time 100 khz mode 250 ? ns (note 2) 400 khz mode 100 ? ns sp109* t aa output valid from clock 100 khz mode ? 3500 ns (note 1) 400 khz mode ? ? ns sp110* t buf bus free time 100 khz mode 4.7 ? ? s time the bus must be free before a new transmission can start 400 khz mode 1.3 ? ? s sp111 c b bus capacitive loading ? 400 pf * these parameters are characterized but not tested. note 1: as a transmitter, the device must provide this internal minimum delay time to bridge the undefined region (min. 300 ns) of the falling edge of scl to avoid unintended generation of start or stop conditions. 2: a fast mode (400 khz) i 2 c ? bus device can be used in a standard mode (100 khz) i 2 c bus system, but the requirement t su : dat ?? 250 ns must then be met. this will automatically be the case if the device does not stretch the low period of the scl signal. if such a device does stretch the low period of the scl signal, it must output the next data bit to the sda line t r max. + t su : dat = 1000 + 250 = 1250 ns (according to the standard mode i 2 c bus specification), before the scl line is released.
pic16f/lf722a/723a ds41417a-page 226 ? 2010 microchip technology inc. table 23-14: cap sense os cillator specifications figure 23-22: cap sense oscillator param. no. symbol characteristic min. typ? max. units conditions cs01 i src current source high ? -5.8 -6 ? a -40, -85c medium ? -1.1 -3.2 ? a low ? -0.2 -0.9 ? a cs02 i snk current sink high ? 6.6 6 ? a -40, -85c medium ? 1.3 3.2 ? a low ? 0.24 0.9 ? a cs03 vc hyst cap hysteresis high ? 525 ? mv vc th -vc tl medium ? 375 ? mv low ? 280 ? mv * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. i src vc th vc tl i snk enabled enabled
? 2010 microchip technology inc. ds41417a-page 227 pic16f/lf722a/723a 24.0 dc and ac characteristics graphs and charts ?typical? represents the mean of the distribution at 25 ? c. ?maximum? or ?minimum? represents (mean + 3 ? ) or (mean - 3 ? ) respectively, where ? is a standard deviation, over the whole temperature range. figure 24-1: pic16f722a/723a maximum i dd vs. f osc over v dd , ec mode, v cap = 0.1f note: the graphs and tables provided following this note are a statistical summary based on a limited number of samples and are provided for informational purposes only. the performance characteristics listed herein are not tested or guaranteed. in some graphs or tables, the data presented may be outside the specified operating range (e.g., outside specified power supply range) and therefore, outside the warranted range. 1.8v 2.5v 3v 3.6v 5v 0.00 200.00 400.00 600.00 800.00 1,000.00 1,200.00 1,400.00 1,600.00 1,800.00 2,000.00 2,200.00 1 mhz 4 mhz 8 mhz 12 mhz 16 mhz 20 mhz v dd (v) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a)
pic16f/lf722a/723a ds41417a-page 228 ? 2010 microchip technology inc. figure 24-2: pic16lf722a/723a maximum i dd vs. f osc over v dd , ec mode figure 24-3: pic16f722a/723a typical i dd vs. f osc over v dd , ec mode, v cap = 0.1f 1.8v 2v 2.5v 3v 3.3v 3.6v 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2,000 2,200 2,400 1 mhz 4 mhz 8 mhz 12 mhz 16 mhz 20 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) f osc i dd (a) 1.8v 2.5v 3v 3.6v 5v 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2,000 1 mhz 4 mhz 8 mhz 12 mhz 16 mhz 20 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) f osc i dd (a)
? 2010 microchip technology inc. ds41417a-page 229 pic16f/lf722a/723a figure 24-4: pic16lf722a/723a typical i dd vs. f osc over v dd , ec mode figure 24-5: pic16f722a/723a maximum i dd vs. v dd over f osc , extrc mode, v cap = 0.1f 1.8v 2v 2.5v 3v 3.3v 3.6v 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2,000 2,200 1 mhz 4 mhz 8 mhz 12 mhz 16 mhz 20 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) f osc 1 mhz 4 mhz 0 100 200 300 400 500 600 1.8 2 2.5 3 3.3 3.6 4.2 4.5 5 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) v dd (v)
pic16f/lf722a/723a ds41417a-page 230 ? 2010 microchip technology inc. figure 24-6: pic16lf722a/723a maximum i dd vs. v dd over f osc , extrc mode figure 24-7: pic16f722a/723a typical i dd vs. v dd over f osc , extrc mode, v cap = 0.1f 1 mhz 4 mhz 0 50 100 150 200 250 300 350 400 450 500 1.8 2 2.5 3 3.3 3.6 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) v dd (v) 1 mhz 4 mhz 0 50 100 150 200 250 300 350 400 450 1.8 2 2.5 3 3.3 3.6 4.2 4.5 5 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) v dd (v) i dd (a)
? 2010 microchip technology inc. ds41417a-page 231 pic16f/lf722a/723a figure 24-8: pic16lf722a/723a typical i dd vs. v dd over f osc , extrc mode figure 24-9: pic16f722a/723a maximum i dd vs. f osc over v dd , hs mode, v cap = 0.1f 1 mhz 4 mhz 0 50 100 150 200 250 300 350 400 450 1.8 2 2.5 3 3.3 3.6 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) v dd (v) i dd (a) 3v 3.6v 4.5v 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.4 4 mhz 6 mhz 8 mhz 10 mhz 13 mhz 16 mhz 20 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) fosc i dd (ma) 5v
pic16f/lf722a/723a ds41417a-page 232 ? 2010 microchip technology inc. figure 24-10: pic16lf722a/723a maximum i dd vs. f osc over v dd , hs mode figure 24-11: pic16f722a/723a typical i dd vs. f osc over v dd , hs mode, v cap = 0.1f 2.5v 3v 3.6v 0.00 0.50 1.00 1.50 2.00 2.50 4 mhz 6 mhz 8 mhz 10 mhz 13 mhz 16 mhz 20 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) fosc i dd (ma) 3.3v 3v 3.6v 4.5v 0.00 0.50 1.00 1.50 2.00 4 mhz 6 mhz 8 mhz 10 mhz 13 mhz 16 mhz 20 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) fosc i dd (ma) 5v
? 2010 microchip technology inc. ds41417a-page 233 pic16f/lf722a/723a figure 24-12: pic16lf722a/723a typical i dd vs. f osc over v dd , hs mode figure 24-13: pic16f722a/723a maximum i dd vs. v dd over f osc , xt mode, v cap = 0.1f 2.5v 3v 3.3v 0.00 0.50 1.00 1.50 2.00 2.50 4 mhz 6 mhz 8 mhz 10 mhz 13 mhz 16 mhz 20 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (ma) fosc 3.6v 1 mhz 4 mhz 0 100 200 300 400 500 600 1.8 2 2.5 3 3.3 3.6 4.2 4.5 5 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) v dd (v)
pic16f/lf722a/723a ds41417a-page 234 ? 2010 microchip technology inc. figure 24-14: pic16lf722a/723a maximum i dd vs. v dd over f osc , xt mode figure 24-15: pic16f722a/723a typical i dd vs. v dd over f osc , xt mode, v cap = 0.1f 1 mhz 4 mhz 0 100 200 300 400 500 600 1.8 2 2.5 3 3.3 3.6 i dd (a) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) v dd (v) 1 mhz 4 mhz 0 100 200 300 400 500 600 1.8 2 2.5 3 3.3 3.6 4.2 4.5 5 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) v dd (v)
? 2010 microchip technology inc. ds41417a-page 235 pic16f/lf722a/723a figure 24-16: pic16lf722a/723a typical i dd vs. v dd over f osc , xt mode figure 24-17: pic16f722a/723a i dd vs. v dd , lp mode, v cap = 0.1f 1 mhz 4 mhz 0 100 200 300 400 500 600 1.8 2 2.5 3 3.3 3.6 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) v dd (v) 32 khz typical 32 khz maximum 10.0 12.5 15.0 17.5 20.0 1.8 3 5 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) v dd (v) v dd (v)
pic16f/lf722a/723a ds41417a-page 236 ? 2010 microchip technology inc. figure 24-18: pic16lf722a/723a i dd vs. v dd , lp mode figure 24-19: pic16f722a/723a maximum i dd vs. f osc over v dd , intosc mode, v cap = 0.1f 32 khz typical 32 khz maximum 5 10 15 20 25 30 1.8 3 3.3 3.6 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) v dd (v) 110 120 130 140 150 160 170 180 190 200 210 62.5 khz 125 khz 250 khz 500 khz 5v 3.6v 1.8v 2.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) f osc i dd (a)
? 2010 microchip technology inc. ds41417a-page 237 pic16f/lf722a/723a figure 24-20: pic16lf722a/723a maximum i dd vs. f osc over v dd , intosc mode figure 24-21: pic16f722a/723a maximum i dd vs. f osc over v dd , intosc mode, v cap = 0.1f 1.8v 2.5v 3v 3.6v 100 110 120 130 140 150 160 170 62.5 khz 125 khz 250 khz 500 khz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) f osc i dd (a) 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2,000 2 mhz 4 mhz 8 mhz 16 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) f osc 1.8v 2.5v 5v 3.6v
pic16f/lf722a/723a ds41417a-page 238 ? 2010 microchip technology inc. figure 24-22: pic16lf722a/723a maximum i dd vs. f osc over v dd , intosc mode figure 24-23: pic16f722a/723a typical i dd vs. f osc over v dd , intosc mode, v cap = 0.1f 1.8v 2.5v 3v 3.6v 0 250 500 750 1,000 1,250 1,500 1,750 2,000 2,250 2 mhz 4 mhz 8 mhz 16 mhz s typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) f osc 1.8v 2.5v 3.6v 5v 80 90 100 110 120 130 140 150 160 62.5 khz 125 khz 250 khz 500 khz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) f osc
? 2010 microchip technology inc. ds41417a-page 239 pic16f/lf722a/723a figure 24-24: pic16lf722a/723a typical i dd vs. f osc over v dd , intosc mode figure 24-25: pic16f722a/723a typical i dd vs. f osc over v dd , intosc mode, v cap = 0.1f 3.6v 1.8v 2.5v 3v 70 80 90 100 110 120 130 140 62.5 khz 125 khz 250 khz 500 khz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) f osc 1.8v 2.5v 3.6v 5v 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2,000 2 mhz 4 mhz 8 mhz 16 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) f osc
pic16f/lf722a/723a ds41417a-page 240 ? 2010 microchip technology inc. figure 24-26: pic16lf722a/723a typical i dd vs. f osc over v dd , intosc mode figure 24-27: pic16f722a/723a maximum base i pd vs. v dd , v cap = 0.1f 3.6v 1.8v 2.5v 3v 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2,000 2 mhz 4 mhz 8 mhz 16 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i dd (a) v dd (v) 85c 125c 0 5 10 15 20 25 1.8v 2v 3v 3.6v 4v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
? 2010 microchip technology inc. ds41417a-page 241 pic16f/lf722a/723a figure 24-28: pic16lf722a/723a maximum base i pd vs. v dd figure 24-29: pic16f722a/723a typical base i pd vs. v dd , v cap = 0.1f 125c 85c 0 1 2 3 4 5 6 7 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v) 25c 2 3 4 5 6 7 8 1.8v 2v 3v 3.6v 4v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
pic16f/lf722a/723a ds41417a-page 242 ? 2010 microchip technology inc. figure 24-30: pic16lf722a/723a typical base i pd vs. v dd figure 24-31: pic16f722a/723a fixed voltage reference i pd vs. v dd , v cap = 0.1f 25c 0 50 100 150 200 250 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (na) v dd (v) typ. 25c max. 125c max. 85c 0 10 20 30 40 50 60 70 1.8v 2v 3v 3.6v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
? 2010 microchip technology inc. ds41417a-page 243 pic16f/lf722a/723a figure 24-32: pic16lf722a/723a fixed voltage reference i pd vs. v dd figure 24-33: pic16f722a/723a bor i pd vs. v dd , v cap = 0.1f typ. 25c max. 125c max. 85c 0 5 10 15 20 25 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v) typ. 25c max. 125c max. 85c 0 10 20 30 40 50 60 70 2v 3v 3.6v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
pic16f/lf722a/723a ds41417a-page 244 ? 2010 microchip technology inc. figure 24-34: pic16lf722a/723a bor i pd vs. v dd figure 24-35: pic16f722a/723a cap sense high power i pd vs. v dd , v cap = 0.1f typ. 25c max. 125c max. 85c 0 5 10 15 20 25 30 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v) typ. 25c max. 125c max. 85c 0 10 20 30 40 50 60 70 1.8v 2v 3v 3.6v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
? 2010 microchip technology inc. ds41417a-page 245 pic16f/lf722a/723a figure 24-36: pic16lf722a/723a cap sense high power i pd vs. v dd figure 24-37: pic16f722a/723a cap sense medium power i pd vs. v dd , v cap = 0.1f typ. 25c max. 125c max. 85c 0 10 20 30 40 50 60 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v) typ. 25c max. 125c max. 85c 0 5 10 15 20 25 30 1.8v 2v 3v 3.6v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
pic16f/lf722a/723a ds41417a-page 246 ? 2010 microchip technology inc. figure 24-38: pic16lf722a/723a cap sense medium power i pd vs. v dd figure 24-39: pic16f722a/723a cap sense low power i pd vs. v dd , v cap = 0.1f typ. 25c max. 125c max. 85c 0 2 4 6 8 10 12 14 16 18 20 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v) typ. 25c max. 125c max. 85c 0 5 10 15 20 25 30 1.8v 2v 3v 3.6v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
? 2010 microchip technology inc. ds41417a-page 247 pic16f/lf722a/723a figure 24-40: pic16lf722a/723a cap sense low power i pd vs. v dd figure 24-41: pic16f722a/723a t1osc 32 khz i pd vs. v dd , v cap = 0.1f typ. 25c max. 125c max. 85c 0 2 4 6 8 10 12 14 16 18 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v) typ. 25 c max. 85c 0 2 4 6 8 10 12 14 16 1.8v 2v 3v 3.6v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
pic16f/lf722a/723a ds41417a-page 248 ? 2010 microchip technology inc. figure 24-42: pic16lf722a/723a t1osc 32 khz i pd vs. v dd figure 24-43: pic16f722a/723a typical adc i pd vs. v dd , v cap = 0.1f typ. max. 85c 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v) typ. 25c 5.0 5.5 6.0 6.5 7.0 7.5 1.8v 2v 3v 3.6v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
? 2010 microchip technology inc. ds41417a-page 249 pic16f/lf722a/723a figure 24-44: pic16lf722a/723a typical adc i pd vs. v dd figure 24-45: pic16f722a/723a adc i pd vs. v dd , v cap = 0.1f typ. 25c 0 50 100 150 200 250 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (na) v dd (v) max. 85c max. 125c 5 10 15 20 25 1.8v 2v 3v 3.6v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
pic16f/lf722a/723a ds41417a-page 250 ? 2010 microchip technology inc. figure 24-46: pic16lf722a/723a adc i pd vs. v dd figure 24-47: pic16f722a/723a wdt i pd vs. v dd , v cap = 0.1f max. 85c max. 125c 0 1 2 3 4 5 6 7 8 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v) typ. 25c max. 85c 0 2 4 6 8 10 12 14 16 18 1.8v 2v 3v 3.6v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v)
? 2010 microchip technology inc. ds41417a-page 251 pic16f/lf722a/723a figure 24-48: pic16lf722a/723a wdt i pd vs. v dd figure 24-49: ttl input threshold v in vs. v dd over temperature typ. 25c max. 85c 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 1.8v 2v 2.5v 3v 3.6v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) i pd (a) v dd (v) max. -40 typ. 25 min. 125 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 1.8 3.6 5.5 maximum: mean + 3 ? (-40c to 125c) minimum: mean - 3 ? (-40c to 125c) v in (v) v dd (v) typical: mean @25c
pic16f/lf722a/723a ds41417a-page 252 ? 2010 microchip technology inc. figure 24-50: schmitt trigger input threshold v in vs. v dd over temperature figure 24-51: schmitt trigger input threshold v in vs. v dd over temperature v ih min. 125c 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 1.8 3.6 5.5 v in (v) v dd (v) v ih max. -40c maximum: mean + 3 ? (-40c to 125c) minimum: mean - 3 ? (-40c to 125c) typical: mean @25c 0.0 0.5 1.0 1.5 2.0 2.5 3.0 1.8 3.6 5.5 v in (v) v dd (v) v il min. 125c v il max. -40c maximum: mean + 3 ? (-40c to 125c) minimum: mean - 3 ? (-40c to 125c) typical: mean @25c
? 2010 microchip technology inc. ds41417a-page 253 pic16f/lf722a/723a figure 24-52: v oh vs. i oh over temperature, v dd = 5.5v figure 24-53: v oh vs. i oh over temperature, v dd = 3.6v max. -40 min. 125 typ. 25 5 5.1 5.2 5.3 5.4 5.5 5.6 -5.0 -4.2 -3.4 -2.6 -1.8 -1.0 -0.2 maximum: mean + 3 ? (-40c to 125c) minimum: mean - 3 ? (-40c to 125c) typical: mean @25c v oh (v) i oh (ma) 2.6 2.8 3 3.2 3.4 3.6 3.8 -5.0 -4.2 -3.4 -2.6 -1.8 -1.0 -0.2 maximum: mean + 3 ? (-40c to 125c) minimum: mean - 3 ? (-40c to 125c) typical: mean @25c v oh (v) i oh (ma) max. -40 typ. 25 min. 125
pic16f/lf722a/723a ds41417a-page 254 ? 2010 microchip technology inc. figure 24-54: v oh vs. i oh over temperature, v dd = 1.8v figure 24-55: v ol vs. i ol over temperature, v dd = 5.5v 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 -2.0 -1.8 -1.6 -1.4 -1.2 -1.0 -0.8 -0.6 -0.4 -0.2 0.0 v oh (v) i oh (ma) max. -40 typ. 25 min. 125 maximum: mean + 3 ? (-40c to 125c) minimum: mean - 3 ? (-40c to 125c) typical: mean @25c min. -40 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 5.0 6.0 7.0 8.0 9.0 10.0 v ol (v) i ol (ma) max. 125 typ. 25 maximum: mean + 3 ? (-40c to 125c) minimum: mean - 3 ? (-40c to 125c) typical: mean @25c
? 2010 microchip technology inc. ds41417a-page 255 pic16f/lf722a/723a figure 24-56: v ol vs. i ol over temperature, v dd = 3.6 figure 24-57: v ol vs. i ol over temperature, v dd = 1.8v min. -40 typ. 25 max. 125 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 4.0 5.0 6.0 7.0 8.0 9.0 10.0 maximum: mean + 3 ? (-40c to 125c) minimum: mean - 3 ? (-40c to 125c) typical: mean @25c v ol (v) i ol (ma) 0 0.2 0.4 0.6 0.8 1 1.2 0.0 0.4 0.8 1.2 1.6 2.0 2.4 2.8 maximum: mean + 3 ? (-40c to 125c) minimum: mean - 3 ? (-40c to 125c) typical: mean @25c v ol (v) i ol (ma) max. 125 min. -40
pic16f/lf722a/723a ds41417a-page 256 ? 2010 microchip technology inc. figure 24-58: pic16f722a/723a pwrt period figure 24-59: pic16f722a/723a wdt time-out period max. -40c min. 125c 45 55 65 75 85 95 105 1.8v 2v 2.2v 2.4v 3v 3.6v 4v 4.5v 5v 5.5v time (ms) v dd typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) typ. 25c typ. 25c max. -40c min. 125c 10.00 12.00 14.00 16.00 18.00 20.00 22.00 24.00 1.8v 2v 2.2v 2.4v 3v 3.6v 4v 4.5v 5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) time (ms) v dd
? 2010 microchip technology inc. ds41417a-page 257 pic16f/lf722a/723a figure 24-60: pic16f722a/723a hfintosc wake-up from sleep start-up time figure 24-61: pic16f722a/723a a/d internal rc oscillator period max. typ. 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 1.8v 2v 3v 3.6v 4v 4.5v 5v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) time (us) v dd max. min. 0.0 1.0 2.0 3.0 4.0 5.0 6.0 1.8v 3.6v 5.5v typical: statistical mean @25c maximum: mean (worst-case temp) + 3 ? (-40c to 125c) period (s) v dd (v)
pic16f/lf722a/723a ds41417a-page 258 ? 2010 microchip technology inc. figure 24-62: pic16f722a/723a cap sens e output current, power mode = high figure 24-63: pic16f722a/723a cap sens e output current, power mode = medium -15000 -10000 -5000 0 5000 10000 15000 20000 1.8 2 2.5 3 3.2 3.6 4 4.5 5 5.5 current (na) v dd (v) min. sink -40c typ. sink 25c max. sink 85c min. source 85c typ. source 25c max. source -40c -3000 -2000 -1000 0 1000 2000 3000 1.8 2 2.5 3 3.2 3.6 4 4.5 5 5.5 current (na) v dd (v) max. sink -40c typ. sink 25c min. sink 85c min. source 85c typ. source 25c max. source -40c
? 2010 microchip technology inc. ds41417a-page 259 pic16f/lf722a/723a figure 24-64: pic16f722a/723a cap sens e output current, power mode = low figure 24-65: pic16f722a/723a cap sensor hysteresis, power mode = high -800 -600 -400 -200 0 200 400 600 1.8 2 2.5 3 3.2 3.6 4 4.5 5 5.5 current (na) v dd (v) max. sink 85c typ. sink 25c min. sink -40c min. source 85c typ. source 25c max. source -40c 300 400 500 600 700 1.8 2.0 2.5 3.0 3.2 3.6 4.0 4.5 5.0 5.5 max. 125c max. 85c typ. 25c min. 0c min. -40c mv v dd (v)
pic16f/lf722a/723a ds41417a-page 260 ? 2010 microchip technology inc. figure 24-66: pic16f722a/723a cap sensor hysteresis, power mode = medium figure 24-67: pic16f722a/723a cap sensor hysteresis, power mode = low 250 300 350 400 450 500 550 1.8 2.0 2.5 3.0 3.2 3.6 4.0 4.5 5.0 5.5 max. 125c typ. 25c min. 0c min. -40c mv v dd (v) max. 85c 150 200 250 300 350 400 450 1.8 2.0 2.5 3.0 3.2 3.6 4.0 4.5 5.0 5.5 max. 125c max. 85c typ. 25c min. 0c mv v dd (v) min -40c
? 2010 microchip technology inc. ds41417a-page 261 pic16f/lf722a/723a figure 24-68: typical fvr (x1 and x2) vs. supply voltage (v) normalized at 3.0v figure 24-69: typical fvr change vs. temperature norm alized at 25c -1.5 -1 -0.5 0 0.5 1 1.5 1.8 2.5 3 3.6 4.2 5.5 voltage percent change (%) -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 -40 0 45 85 125 temperature (c) percent change (%)
pic16f/lf722a/723a ds41417a-page 262 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 263 pic16f/lf722a/723a 25.0 packaging information 25.1 package marking information * standard picmicro ? device marking consists of microchip part number, year code, week code and traceability code. for picmicro device marking beyond this, certain price adders apply. please check with your microchip sales office. for qtp devices, any special marking adders are included in qtp price. legend: xx...x customer-specific information y year code (last digit of calendar year) yy year code (last 2 digits of calendar year) ww week code (week of january 1 is week ?01?) nnn alphanumeric traceability code pb-free jedec designator for matte tin (sn) * this package is pb-free. the pb-free jedec designator ( ) can be found on the outer packaging for this package. note : in the event the full microchip part number cannot be marked on one line, it will be carried over to the next line, thus limiting the number of available characters for customer-specific information. 3 e 3 e 3 e 28-lead spdip xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx yywwnnn example pic16f722a 0810017 -i/sp example 28-lead qfn/uqfn xxxxxxxx xxxxxxxx yywwnnn 16f722a -i/ml 0810017 3 e 28-lead soic xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx yywwnnn example 0810017 -i/so 3 e pic16f722a 28-lead ssop xxxxxxxxxxxx xxxxxxxxxxxx yywwnnn example pic16f722a 0810017 -i/ss 3 e
pic16f/lf722a/723a ds41417a-page 264 ? 2010 microchip technology inc. 25.2 package details the following sections give the technical details of the packages. 
       
      
 !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   +%&,  & !& - '!
!#.#

&"#'
#%! 

& "!
!
#%! 

& "!
!! 
&$#/  !#  '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 7,8. '!
9'&! 7 7: ; 7"') 
%! 7 < &  1,
&
&  = =  
##4 4!!   -  1!&
&   = = 
"# &

"# >#& .  - -- 
##4>#& .  <  :  9&  - -?   &
& 9  -  9# 4!!  <   6  9#>#& )    9
* 9#>#& )  <  :  
* + 1 = = - note 1 n 12 d e1 eb c e l a2 e b b1 a1 a 3 
   

  * ,1
? 2010 microchip technology inc. ds41417a-page 265 pic16f/lf722a/723a    # $% !   & '  ()(   #$! * + ,--  .   &+ !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   4!!*!"&# - '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! .32 % '!
("!"*&
"&&
 (%
%
'&
 "
!!
 !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 99. . '!
9'&! 7 7: ; 7"') 
%! 7 < &  ?1, :  8 &  <   &#
%%     ,
&& 4!! - .3 :  >#& . ?1, .$
!##>#& . -? -  :  9&  ?1, .$
!##9&  -? -  ,
&&>#& ) - - - ,
&&9& 9    ,
&&&
.$
!## @  = = d exposed d2 e b k e2 e l n note 1 1 2 2 1 n a a1 a3 top view bottom view pad 
   

  * ,1
pic16f/lf722a/723a ds41417a-page 266 ? 2010 microchip technology inc.    # $% !   & '  ()(   #$! * + ,--  .   &+ !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4
? 2010 microchip technology inc. ds41417a-page 267 pic16f/lf722a/723a note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging
pic16f/lf722a/723a ds41417a-page 268 ? 2010 microchip technology inc. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging
? 2010 microchip technology inc. ds41417a-page 269 pic16f/lf722a/723a   
 /  
/  0 % 1,-   
/. !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   +%&,  & !& - '!
!#.#

&"#'
#%! 

& "!
!
#%! 

& "!
!! 
&$#''  !#  '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! .32 % '!
("!"*&
"&&
 (%
%
'&
 "
!!
 !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 99. . '!
9'&! 7 7: ; 7"') 
%! 7 < &  1, :  8 &  = = ? 
##4 4!!   = = &#
%%+   = - :  >#& . -1, 
##4>#& . 1, :  9&  1, , '% a
&
b  =  3
&9& 9  =  3
& & 9 .3 3
&
c = #& ) - =  
# %&
c = c 
# %&1
&&
' c = c c h h l l1 a2 a1 a note 1 12 3 b e e e1 d n 
   

  * ,1
pic16f/lf722a/723a ds41417a-page 270 ? 2010 microchip technology inc. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging
? 2010 microchip technology inc. ds41417a-page 271 pic16f/lf722a/723a   
+2
 /  
  -,   
/ !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   '!
!#.#

&"#'
#%! 

& "!
!
#%! 

& "!
!! 
&$#''  !# - '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! .32 % '!
("!"*&
"&&
 (%
%
'&
 "
!!
 !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 99. . '!
9'&! 7 7: ; 7"') 
%! 7 < &  ?1, :  8 &  = =  
##4 4!!  ?  < &#
%%   = = :  >#& .  < < 
##4>#& .  - ? :  9&     3
&9& 9    3
& & 9 .3 9# 4!!   =  3
& c c #& )  = -< l l1 c a2 a1 a e e1 d n 1 2 note 1 b e 
   

  * ,-1
pic16f/lf722a/723a ds41417a-page 272 ? 2010 microchip technology inc. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging
? 2010 microchip technology inc. ds41417a-page 273 pic16f/lf722a/723a appendix a: data sheet revision history revision a (april 2010) original release of this data sheet. appendix b: migrating from other pic ? devices this discusses some of the issues in migrating from other pic ? devices to the pic16f722a/723a family of devices. b.1 pic16f77 to pic16f722a/723a note: this device has been designed to perform to the parameters of its data sheet. it has been tested to an electrical specification designed to determine its conformance with these parameters. due to process differences in the manufacture of this device, this device may have different performance characteristics than its ealier version. these differences may cause this device to perform differently in your application than the earlier version of this device. note: the user should verify that the device oscillator starts and performs as expected. adjusting the loading capacitor values and/or the oscillator mode may be required. table b-1: feature comparison feature pic16f77 pic16f722a/ 723a max. operating speed 20 mhz 20 mhz max. program memory (words) 8k 4k max. sram (bytes) 368 192 a/d resolution 8-bit 8-bit timers (8/16-bit) 2/1 2/1 oscillator modes 4 8 brown-out reset y y internal pull-ups rb<7:0> rb<7:0> interrupt-on-change rb<7:4> rb<7:0> comparator 0 0 usart y y extended wdt n n software control option of wdt/bor nn intosc frequencies none 500 khz - 16 mhz clock switching n n
pic16f/lf722a/723a ds41417a-page 274 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 275 pic16f/lf722a/723a index a a/d specifications............................................................ 218 absolute maximum ratings .............................................. 199 ac characteristics industrial and extended ............................................ 210 load conditions ........................................................ 209 adc .................................................................................... 87 acquisition requirements ........................................... 94 associated registers.................................................... 96 block diagram............................................................. 87 calculating acquisition time....................................... 94 channel selection....................................................... 88 configuration............................................................... 88 configuring interrupt ................................................... 91 conversion clock........................................................ 88 conversion procedure ................................................ 91 internal sampling switch (r ss ) i mpedance ................ 94 interrupts..................................................................... 90 operation .................................................................... 90 operation during sleep .............................................. 90 port configuration ....................................................... 88 reference voltage (v ref )........................................... 88 source impedance...................................................... 94 special event trigger.................................................. 90 adcon0 register......................................................... 19, 92 adcon1 register......................................................... 20, 93 addressable universal synchronous asynchronous receiver transmitter (ausart)............................... 133 adres register ........................................................... 19, 93 alternate pin function......................................................... 47 analog-to-digital converter. see adc ansela register ............................................................... 49 anselb register ............................................................... 58 apfcon register......................................................... 20, 47 assembler mpasm assembler................................................... 196 ausart ........................................................................... 133 associated registers baud rate generator........................................ 144 asynchronous mode ................................................. 135 associated registers receive..................................................... 141 transmit.................................................... 137 baud rate generator (brg) ............................ 144 receiver............................................................ 138 setting up 9-bit mode with address detect....... 140 transmitter........................................................ 135 baud rate generator (brg) baud rate error, calculating ............................ 144 baud rates, asynchronous modes .................. 145 formulas ........................................................... 144 high baud rate select (brgh bit) .................. 144 synchronous master mode ............................... 147, 151 associated registers receive..................................................... 150 transmit.................................................... 148 reception.......................................................... 149 transmission .................................................... 147 synchronous slave mode associated registers receive..................................................... 152 transmit.................................................... 151 reception ......................................................... 152 transmission .................................................... 151 b bf bit ........................................................................ 163, 175 block diagram capacitive sensing................................................... 117 block diagrams (ccp) capture mode operation ............................... 125 adc ............................................................................ 87 adc transfer function ............................................... 95 analog input model..................................................... 95 ausart receive ..................................................... 134 ausart transmit .................................................... 133 ccp pwm ................................................................ 129 clock source .............................................................. 77 compare................................................................... 127 crystal operation........................................................ 81 external rc mode ...................................................... 82 interrupt logic............................................................. 37 mclr circuit .............................................................. 29 on-chip reset circuit................................................. 27 pic16f/lf722a/723a ................................................ 10 ra0 pins..................................................................... 51 ra4 pin ...................................................................... 52 ra5 pin ...................................................................... 53 ra6 pin ...................................................................... 54 ra7 pin ...................................................................... 54 rb0 pin ...................................................................... 60 rb3 pin ...................................................................... 62 rb4, rb2, rb1 pins................................................... 61 rb5 pin ...................................................................... 63 rb6 pin ...................................................................... 64 rb7 pin ...................................................................... 65 rc0 pin ...................................................................... 69 rc1 pin ...................................................................... 69 rc2 pin ...................................................................... 70 rc3 pin ...................................................................... 70 rc4 pin ...................................................................... 71 rc5 pin ...................................................................... 71 rc6 pin ...................................................................... 72 rc7 pin ...................................................................... 72 re3 pin ...................................................................... 75 resonator operation .................................................. 82 spi mode.................................................................. 156 ssp (i 2 c mode)........................................................ 165 timer1 .............................................. 103, 109, 110, 111 timer2 ...................................................................... 115 tmr0/wdt prescaler ................................................ 99 brown-out reset (bor)...................................................... 31 specifications ........................................................... 216 timing and characteristics ....................................... 215 c c compilers mplab c18 .............................................................. 196 capacitive sensing ........................................................... 117 associated registers w/ capacitive sensing............. 122 capture module. see capture/compare/pwm (ccp) capture/compare/pwm (ccp) ........................................ 123 associated registers w/ capture............................... 126 associated registers w/ compare............................. 128 associated registers w/ pwm................................... 132 capture mode ........................................................... 125
pic16f/lf722a/723a ds41417a-page 276 ? 2010 microchip technology inc. ccpx pin configuration ............................................ 125 compare mode ......................................................... 127 ccpx pin configuration .................................... 127 software interrupt mode ........................... 125, 127 special event trigger........................................ 127 timer1 mode selection ............................. 125, 127 interaction of two ccp modules (table) ................... 123 prescaler................................................................... 125 pwm mode ............................................................... 129 duty cycle......................................................... 130 effects of reset................................................. 131 example pwm frequencies and resolutions, 20 mhz ................................ 131 example pwm frequencies and resolutions, 8 mhz................................... 131 operation in sleep mode .................................. 131 setup for operation........................................... 131 system clock frequency changes................... 131 pwm period .............................................................. 130 setup for pwm operation ......................................... 131 timer resources....................................................... 123 ccp. see capture/compare/pwm (ccp) ccp1con register ............................................................ 19 ccp2con register ............................................................ 19 ccpr1h register ............................................................... 19 ccpr1l register................................................................ 19 ccpr2h register ............................................................... 19 ccpr2l register................................................................ 19 ccpxcon register .......................................................... 124 cke bit ...................................................................... 163, 175 ckp bit ...................................................................... 162, 174 clock sources external modes ........................................................... 81 ec ....................................................................... 81 hs ....................................................................... 81 lp........................................................................ 81 ost..................................................................... 81 rc....................................................................... 82 xt ....................................................................... 81 code examples a/d conversion ........................................................... 91 changing between capture prescalers .................... 125 indirect addressing ..................................................... 26 initializing porta....................................................... 48 initializing portb....................................................... 56 initializing portc....................................................... 67 initializing porte....................................................... 74 loading the sspbuf (sspsr) register .................. 158 saving w, status and pclath registers in ram ................................................................ 39 comparators c2out as t1 gate ................................................... 106 compare module. see capture/compare/pwm (ccp) config1 register........................................................ 83, 84 cpscon0 register .......................................................... 121 cpscon1 register .......................................................... 122 customer change notification service ............................. 281 customer notification service........................................... 281 customer support ............................................................. 281 d d/a bit ............................................................................... 175 data memory....................................................................... 16 data/address bit (d/a ) ...................................................... 175 dc and ac characteristics ............................................... 227 dc characteristics extended and industrial ............................................ 206 industrial and extended ............................................ 200 development support ....................................................... 195 device configuration .......................................................... 83 code protection .......................................................... 85 configuration word..................................................... 83 user id ....................................................................... 85 device overview................................................................... 9 e effects of reset pwm mode ............................................................... 131 electrical specifications .................................................... 199 enhanced capture/compare/pwm (eccp) specifications ........................................................... 217 errata .................................................................................... 8 f firmware instructions ....................................................... 185 fixed voltage reference. see fvr fsr register ................................................................ 19, 20 fuses. see configuration bits fvr..................................................................................... 97 fvrcon register ........................................................ 20, 97 g general purpose register file ........................................... 16 i i 2 c mode associated registers ................................................ 176 indf register ............................................................... 19, 20 indirect addressing, indf and fsr registers ................... 26 instruction format............................................................. 185 instruction set................................................................... 185 addlw..................................................................... 187 addwf..................................................................... 187 andlw..................................................................... 187 andwf..................................................................... 187 movf ....................................................................... 190 bcf .......................................................................... 187 bsf........................................................................... 187 btfsc ...................................................................... 187 btfss ...................................................................... 188 call......................................................................... 188 clrf ........................................................................ 188 clrw ....................................................................... 188 clrwdt .................................................................. 188 comf ....................................................................... 188 decf ........................................................................ 188 decfsz ................................................................... 189 goto ....................................................................... 189 incf ......................................................................... 189 incfsz..................................................................... 189 iorlw ...................................................................... 189 iorwf...................................................................... 189 movlw .................................................................... 190 movwf .................................................................... 190 nop .......................................................................... 190 retfie ..................................................................... 191 retlw ..................................................................... 191 return................................................................... 191 rlf ........................................................................... 192 rrf .......................................................................... 192 sleep ...................................................................... 192 sublw ..................................................................... 192
? 2010 microchip technology inc. ds41417a-page 277 pic16f/lf722a/723a subwf ..................................................................... 193 swapf ..................................................................... 193 xorlw..................................................................... 193 xorwf..................................................................... 193 summary table......................................................... 186 intcon register................................................................ 40 internal oscillator block intosc specifications.................................................... 213 internal sampling switch (r ss ) i mpedance ........................ 94 internet address................................................................ 281 interrupts............................................................................. 37 adc ............................................................................ 91 associated registers w/ interrupts............................... 44 interrupt-on-change.................................................... 56 tmr1 ........................................................................ 108 intosc specifications ..................................................... 213 iocb register..................................................................... 58 l load conditions ................................................................ 209 m mclr .................................................................................. 29 internal ........................................................................ 29 memory organization.......................................................... 15 data ............................................................................ 16 program ...................................................................... 15 microchip internet web site .............................................. 281 migrating from other pic microcontroller devices............. 273 mplab asm30 assembler, linker, librarian ................... 196 mplab integrated development environment software .. 195 mplab pm3 device programmer .................................... 198 mplab real ice in-circuit emulator system................. 197 mplink object linker/mplib object librarian ................ 196 o opcode field descriptions ............................................. 185 option register................................................................ 23 option_reg register .................................................... 101 osccon register.............................................................. 79 oscillator associated registers............................................ 82, 114 oscillator module ec ............................................................................... 77 hs ............................................................................... 77 intosc ...................................................................... 77 intoscio................................................................... 77 lp................................................................................ 77 oscillator tuning ......................................................... 80 rc............................................................................... 77 rcio ........................................................................... 77 xt ............................................................................... 77 oscillator parameters ....................................................... 213 oscillator specifications.................................................... 212 oscillator start-up timer (ost) specifications............................................................ 216 osctune register ............................................................ 80 p p (stop) bit ........................................................................ 175 packaging ......................................................................... 263 marking ..................................................................... 263 pdip details.............................................................. 264 paging, program memory ................................................... 25 pcl and pclath ............................................................... 25 computed goto ....................................................... 25 stack........................................................................... 25 pcl register ................................................................ 19, 20 pclath register ......................................................... 19, 20 pcon register ....................................................... 20, 24, 32 pie1 register ............................................................... 20, 41 pie2 register ............................................................... 20, 42 pin diagram pic16f/lf722a/723a, 28-pin pdip/soic/ssop/qfn/ uqfn ................................................................... 5 pinout descriptions pic16f722a/723a...................................................... 11 pir1 register ............................................................... 19, 43 pir2 register ............................................................... 19, 44 pmadrh register............................................................ 179 pmadrl register ............................................................ 179 pmcon1 register .............................................. 21, 178, 179 pmdath register ............................................................ 178 pmdatl register............................................................. 178 porta ............................................................................... 48 ansela register ....................................................... 49 associated registers.................................................. 55 pin descriptions and diagrams .................................. 50 porta register......................................................... 19 ra0............................................................................. 50 ra1............................................................................. 50 ra2............................................................................. 50 ra3............................................................................. 50 ra4............................................................................. 50 ra5............................................................................. 50 ra6............................................................................. 50 ra7............................................................................. 50 specifications ........................................................... 214 porta register ................................................................. 48 portb ............................................................................... 56 additional pin functions anselb register ............................................... 56 weak pull-up ...................................................... 56 associated registers.................................................. 66 interrupt-on-change ................................................... 56 p1b/p1c/p1d. see enhanced capture/compare/ pwm+ (eccp+) ................................................. 56 pin descriptions and diagrams .................................. 59 portb register......................................................... 19 rb0............................................................................. 59 rb1............................................................................. 59 rb2............................................................................. 59 rb3............................................................................. 59 rb4............................................................................. 59 rb5............................................................................. 59 rb6............................................................................. 59 rb7............................................................................. 59 portb register ................................................................. 57 portc ............................................................................... 67 associated registers.................................................. 73 p1a. see enhanced capture/compare/pwm+ (eccp+) ............................................................. 67 portc register......................................................... 19 rc0 ............................................................................ 68 rc2 ............................................................................ 68 rc3 ............................................................................ 68 rc4 ............................................................................ 68 rc5 ............................................................................ 68 rc6 ............................................................................ 68 rc7 ............................................................................ 68
pic16f/lf722a/723a ds41417a-page 278 ? 2010 microchip technology inc. specifications............................................................ 214 portc register ................................................................. 67 porte................................................................................ 74 associated registers .................................................. 74 porte register ......................................................... 19 re0 ............................................................................. 75 re3 ............................................................................. 75 porte register ................................................................. 74 power-down mode (sleep) ............................................... 181 associated registers ................................................ 182 power-on reset .................................................................. 29 power-up timer (pwrt)..................................................... 29 specifications............................................................ 216 pr2 register............................................................... 20, 164 precision internal oscillator parameters........................... 213 prescaler shared wdt/timer0 ................................................. 100 product identification system............................................ 283 program memory ................................................................ 15 map and stack (pic16f/lf722a) ............................... 15 map and stack (pic16f/lf723a) ............................... 15 paging ......................................................................... 25 program memory read (pmr) ......................................... 177 associated registers ................................................ 179 programming, device instructions .................................... 185 r r/w bit .............................................................................. 175 rcreg ............................................................................. 140 rcreg register................................................................. 19 rcsta register.......................................................... 19, 143 reader response ............................................................. 282 read-modify-write operations.......................................... 185 receive overflow indicator bit (sspov)................... 162, 174 registers adcon0 (adc control 0) .......................................... 92 adcon1 (adc control 1) .......................................... 93 adres (adc result) ................................................. 93 ansela (porta analog select)............................... 49 anselb (portb analog select)............................... 58 apfcon (alternate pin function control).................. 47 ccpxcon (ccp operation) ..................................... 124 config1 (configuration word register 1) .......... 83, 84 cpscon0 (capacitive sensing control register 0). 121 cpscon1 (capacitive sensing control register 1). 122 fvrcon (fixed voltage reference register) ........... 97 intcon (interrupt control) ......................................... 40 iocb (interrupt-on-change portb) .......................... 58 option_reg (option) ........................................... 23 option_reg (option) ............................................ 101 osccon (oscillator control) ..................................... 79 osctune (oscillator tuning) .................................... 80 pcon (power control register) ................................. 24 pcon (power control) ............................................... 32 pie1 (peripheral interrupt enable 1) ........................... 41 pie2 (peripheral interrupt enable 2) ........................... 42 pir1 (peripheral interrupt register 1) ........................ 43 pir2 (peripheral interrupt request 2) ........................ 44 pmadrh (program memory address high)............. 179 pmadrl (program memory address low) .............. 179 pmcon1 (program memory control 1) .................... 178 pmdath (program memory data high)................... 178 pmdatl (program memory data low) .................... 178 porta........................................................................ 48 portb........................................................................ 57 portc ....................................................................... 67 porte ....................................................................... 74 rcsta (receive status and control) ...................... 143 reset values .............................................................. 34 reset values (special registers) ............................... 36 special function register map pic16f/lf723a.................................................. 18 special function, summary........................................ 19 sspcon (sync serial port control) register .. 162, 174 sspstat (sync serial port status) register... 163, 175 status ..................................................................... 22 t1con (timer1 control) .......................................... 112 t1gcon (timer1 gate control)............................... 113 t2con ..................................................................... 116 trisa (tri-state porta)........................................... 48 trisb (tri-state portb)........................................... 57 trisc (tri-state portc) .......................................... 67 trise (tri-state porte)........................................... 74 txsta (transmit status and control) ...................... 142 wpub (weak pull-up portb)................................... 57 reset .................................................................................. 27 resets associated registers .................................................. 36 revision history................................................................ 273 s s (start) bit........................................................................ 175 smp bit ..................................................................... 163, 175 software simulator (mplab sim) .................................... 197 spbrg ............................................................................. 144 spbrg register................................................................. 20 special event trigger ......................................................... 90 special function registers ................................................. 16 special function registers (sfrs)..................................... 19 spi mode .......................................................................... 161 associated registers ................................................ 164 typical master/slave connection ............................. 155 ssp................................................................................... 155 i 2 c mode .................................................................. 165 acknowledge .................................................... 166 addressing........................................................ 167 clock stretching ............................................... 172 clock synchronization ...................................... 173 firmware master mode..................................... 172 hardware setup................................................ 165 multi-master mode............................................ 172 reception ......................................................... 168 sleep operation................................................ 173 start/stop conditions........................................ 166 transmission .................................................... 170 master mode............................................................. 157 spi mode .................................................................. 155 slave mode....................................................... 159 typical spi master/slave connection ...................... 155 sspadd register............................................................... 20 sspbuf register ............................................................... 19 sspcon register .............................................. 19, 162, 174 sspen bit................................................................. 162, 174 sspm bits ................................................................. 162, 174 sspmsk register .............................................................. 20 sspov bit................................................................. 162, 174 sspstat register ............................................. 20, 163, 175 status register ............................................................... 22 synchronous serial port enable bit (sspen) .......... 162, 174 synchronous serial port mode select bits (sspm).. 162, 174
? 2010 microchip technology inc. ds41417a-page 279 pic16f/lf722a/723a t t1con register ......................................................... 19, 112 tmr1on bit.............................................................. 113 t1gcon register............................................................. 113 t2con register ................................................. 19, 116, 164 thermal considerations.................................................... 208 time-out sequence............................................................. 32 timer0 ................................................................................. 99 associated registers ................................................ 101 interrupt..................................................................... 101 operation ............................................................ 99, 104 specifications............................................................ 217 timer1 ............................................................................... 103 associated registers.................................................. 114 asynchronous counter mode ................................... 105 reading and writing ......................................... 105 interrupt..................................................................... 108 modes of operation .................................................. 104 module on/off (tmr1on bit)................................... 113 operation during sleep ............................................ 108 oscillator ................................................................... 105 prescaler................................................................... 105 specifications............................................................ 217 timer1 gate selecting source............................................... 106 tmr1h register ....................................................... 103 tmr1l register........................................................ 103 timer2 associated registers.................................................. 116 timers timer1 t1con.............................................................. 112 t1gcon ........................................................... 113 timer2 t2con.............................................................. 116 timing diagrams a/d conversion......................................................... 219 a/d conversion (sleep mode) .................................. 219 asynchronous reception .......................................... 140 asynchronous transmission..................................... 136 asynchronous transmission (back-to-back) ............ 136 brown-out reset (bor) ............................................ 215 brown-out reset situations ........................................ 31 clkout and i/o....................................................... 213 clock synchronization .............................................. 173 clock timing ............................................................. 210 enhanced capture/compare/pwm (eccp) ............. 217 i 2 c bus data ............................................................. 224 i 2 c bus start/stop bits.............................................. 223 i 2 c reception (7-bit address) ................................... 168 i 2 c slave mode with sen = 0 (reception, 10-bit address) ................................................. 169 i 2 c transmission (7-bit address).............................. 170 int pin interrupt.......................................................... 38 reset, wdt, ost and power-up timer ................... 214 slave select synchronization ................................... 161 spi master mode ...................................................... 158 spi master mode (cke = 1, smp = 1) ..................... 221 spi mode (slave mode with cke = 0) ...................... 160 spi mode (slave mode with cke = 1) ...................... 160 spi slave mode (cke = 0) ....................................... 222 spi slave mode (cke = 1) ....................................... 222 synchronous reception (master mode, sren) ....... 150 synchronous transmission....................................... 148 synchronous transmission (through txen) ........... 148 time-out sequence case 1 ................................................................ 33 case 2 ................................................................ 33 case 3 ................................................................ 33 timer0 and timer1 external clock ........................... 216 timer1 incrementing edge ....................................... 108 usart synchronous receive (master/slave) ......... 220 usart synchronous transmission (master/slave). 220 wake-up from interrupt............................................. 182 timing parameter symbology .......................................... 209 timing requirements i 2 c bus data............................................................. 225 i2c bus start/stop bits............................................. 224 spi mode.................................................................. 223 tmr0 register.................................................................... 19 tmr1h register ................................................................. 19 tmr1l register.................................................................. 19 tmr2 register.................................................................... 19 tmro register................................................................... 21 trisa ................................................................................. 48 trisa register............................................................. 20, 48 trisb ................................................................................. 56 trisb register............................................................. 20, 57 trisc ................................................................................. 67 trisc register............................................................. 20, 67 trise ................................................................................. 74 trise register............................................................. 20, 74 txreg ............................................................................. 135 txreg register ................................................................. 19 txsta register.......................................................... 20, 142 brgh bit .................................................................. 144 u ua..................................................................................... 175 update address bit, ua .................................................... 175 usart synchronous master mode requirements, synchronous receive .............. 220 requirements, synchronous transmission...... 220 timing diagram, synchronous receive ........... 220 timing diagram, synchronous transmission... 220 v v ref . s ee adc reference voltage w wake-up using interrupts ................................................. 182 watchdog timer (wdt)...................................................... 29 clock source .............................................................. 29 period ......................................................................... 29 specifications ........................................................... 216 wcol bit .................................................................. 162, 174 wpub register................................................................... 57 write collision detect bit (wcol) ............................ 162, 174 www address ................................................................. 281 www, on-line support ..................... .................................. 8
pic16f/lf722a/723a ds41417a-page 280 ? 2010 microchip technology inc. notes:
? 2010 microchip technology inc. ds41417a-page 281 pic16f/lf722a/723a the microchip web site microchip provides online support via our www site at www.microchip.com. this web site is used as a means to make files and information easily available to customers. accessible by using your favorite internet browser, the web site contains the following information: ? product support ? data sheets and errata, application notes and sample programs, design resources, user?s guides and hardware support documents, latest software releases and archived software ? general technical support ? frequently asked questions (faq), technical support requests, online discussion groups, microchip consultant program member listing ? business of microchip ? product selector and ordering guides, latest microchip press releases, listing of seminars and events, listings of microchip sales offices, distributors and factory representatives customer change notification service microchip?s customer notification service helps keep customers current on microchip products. subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest. to register, access the microchip web site at www.microchip.com, click on customer change notification and follow the registration instructions. customer support users of microchip products can receive assistance through several channels: ? distributor or representative ? local sales office ? field application engineer (fae) ? technical support ? development systems information line customers should contact their distributor, representative or field application engineer (fae) for support. local sales offices are also available to help customers. a listing of sales offices and locations is included in the back of this document. technical support is available through the web site at: http://support.microchip.com
pic16f/lf722a/723a ds41417a-page 282 ? 2010 microchip technology inc. reader response it is our intention to provide you with the best documentation possible to ensure successful use of your microchip prod- uct. if you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation can better serve you, please fax your comments to the technical publications manager at (480) 792-4150. please list the following information, and use this outline to provide us with your comments about this document. to : technical publications manager re: reader response total pages sent ________ from: name company address city / state / zip / country telephone: (_______) _________ - _________ application (optional): would you like a reply? y n device: literature number: questions: fax: (______) _________ - _________ ds41417a pic16f/lf722a/723a 1. what are the best features of this document? 2. how does this document meet your hardware and software development needs? 3. do you find the organization of this document easy to follow? if not, why? 4. what additions to the document do you think would enhance the structure and subject? 5. what deletions from the document could be made without affecting the overall usefulness? 6. is there any incorrect or misleading information (what and where)? 7. how would you improve this document?
? 2010 microchip technology inc. ds41417a-page 283 pic16f/lf722a/723a product identification system to order or obtain information, e. g., on pricing or delivery, refer to the factory or the listed sales office . part no. x /xx xxx pattern package temperature range device device: pic16f722a, pic16lf722a, pic16f722at, pic16lf722at (1) pic16f723a, PIC16LF723A, pic16f723at, PIC16LF723At (1) temperature range: i= -40 ? c to+85 ? c e= -40 ? c to+125 ? c package: mv = micro lead frame (uqfn) ml = micro lead frame (qfn) so = soic sp = skinny plastic dip ss = ssop pattern: 3-digit pattern code for qtp (blank otherwise) examples: a) pic16f722a-e/sp 301 = extended temp., skinny pdip package, qtp pat- tern #301 b) pic16f722a-i/so = industrial temp., soic package note1: t = in tape and reel.
ds41417a-page 284 ? 2010 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://support.microchip.com web address: www.microchip.com atlanta duluth, ga tel: 678-957-9614 fax: 678-957-1455 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 cleveland independence, oh tel: 216-447-0464 fax: 216-447-0643 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 kokomo kokomo, in tel: 765-864-8360 fax: 765-864-8387 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 santa clara santa clara, ca tel: 408-961-6444 fax: 408-961-6445 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific asia pacific office suites 3707-14, 37th floor tower 6, the gateway harbour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8528-2100 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8665-5511 fax: 86-28-8665-7889 china - chongqing tel: 86-23-8980-9588 fax: 86-23-8980-9500 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - nanjing tel: 86-25-8473-2460 fax: 86-25-8473-2470 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8203-2660 fax: 86-755-8203-1760 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xian tel: 86-29-8833-7252 fax: 86-29-8833-7256 china - xiamen tel: 86-592-2388138 fax: 86-592-2388130 china - zhuhai tel: 86-756-3210040 fax: 86-756-3210049 asia/pacific india - bangalore tel: 91-80-3090-4444 fax: 91-80-3090-4123 india - new delhi tel: 91-11-4160-8631 fax: 91-11-4160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - daegu tel: 82-53-744-4301 fax: 82-53-744-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - kuala lumpur tel: 60-3-6201-9857 fax: 60-3-6201-9859 malaysia - penang tel: 60-4-227-8870 fax: 60-4-227-4068 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-6578-300 fax: 886-3-6578-370 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2500-6610 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-39 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 w orldwide s ales and s ervice 01/05/10


▲Up To Search▲   

 
Price & Availability of PIC16LF723A

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X